home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
utility
/
batpwr02.zip
/
BATPWR02.610
next >
Wrap
Text File
|
1996-10-02
|
419KB
|
10,309 lines
─ Area: Batch Language Programming FI ────────────────────
Msg#: 423 Date: 27 Feb 96 23:40:00
From: Vernon Frazee Read: Yes Replied: No
To: Furlan Primus Mark:
Subj: L-O-N-G PATH 1/2
──────────────────────────────────────────────────────────────────────────────
VF> BTW, I have shown more than a few folks how a PATH of up to at least
VF> 4,096 bytes (yep, that's four-thousand-and-ninety-six characters)
VF> can be created and successfully used... using nothing more than DOS.
FP> i have always kept my PATH to the mininum needed as a matter of
FP> choice
Same on this end (it's faster).
FP> and just exactly HOW do you do the above anyway???
--------------------------------------------------------------------
L-o-n-g PATH "how to" for MS-DOS version 6.nn (any version of DOS 6)
--------------------------------------------------------------------
Normally, on most MS-DOS v6.xx systems, when the system boots it
looks for and loads/runs the following five files -- in this order:
1) IO.SYS - basic Input/Output routines
2) MSDOS.SYS - basic MicroSoft Disk Operating System routines
3) CONFIG.SYS - user created ASCII file (drivers, etc.)
4) COMMAND.COM - command line processor
5) AUTOEXEC.BAT - user created ASCII file (whatever)
The 4th step, loading COMMAND.COM, is what limits the command line,
and hence the "PATH=..." line length in AUTOEXEC.BAT, to a maximum
of 127 characters.
The 'secret' to creating a l-o-n-g PATH then is to set it up in
CONFIG.SYS -- before COMMAND.COM's 127 character line limit has
come in to play -- instead of in AUTOEXEC.BAT.
Setting up a PATH in CONFIG.SYS only works, (I believe), in MS-DOS
v6.xx or higher and uses the following syntax:
SET PATH=drive:\directory[;drive:\directory][;...]
Tip: All of the following examples will NOT work in CONFIG.SYS like
they do in AUTOEXEC.BAT:
PATH=... PATH=%PATH%;... SET PATH=%PATH%;...
PATH ... PATH %PATH%;... SET PATH %PATH%;...
In other words, if the line doesn't begin with "SET PATH=", DOS
will return something like "Error in CONFIG.SYS line 1".
The %PATH% idea also fails because the program that defines and
understands such, COMMAND.COM, has not been loaded yet.
PATH lengths of up to a whopping 4,096 characters have been tested
here, with success, using this "CONFIG.SYS" "SET PATH=..." approach.
--------------------------------------------------------------------
[ ... text deleted for brevity ... ]
-!-
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 431 Date: 04 Mar 96 13:28:05
From: Vernon Frazee Read: Yes Replied: No
To: Carlo Mosti Mark:
Subj: Daily execution
──────────────────────────────────────────────────────────────────────────────
CM> I would like to know if someone knows of a way to resolve my problem
CM> by using only batchfile commands. I want to execute a program
CM> everyday but only once! How do I control that?
Here's one that does it by storing the command you entered plus the
current system date on one line at the end of the BATch file itself.
When you launch it again it simply looks for an identical command-
line/date. (If one is found it tells you that command has already
been run today. If no match is found, it adds the command and date
to the end of the file and continues).
Note: Because this is a self-modifying BATch file, you may need to
change all occurances of "C:\BAT" to the location of where you
intend on keeping it on your hard drive.
@echo off
:ONCEADAY.BAT runs a specified program once-a-day only -----------------
:Notes: This BATch file is self modifying! It keeps track of every date
: and the command(s) issued on that date at end of this file.
: Requires DOS's FIND (somewhere in current PATH is fine).
: Use "CURRENT /C" (not the quotes) to clear all dates from file.
:-----------------------------------------------------------------------
if (%1%2)==(dateis) goto GOTIT
if (%1)==(/?) goto SYNTAX
if (%1)==() goto SYNTAX
for %%x in (:) do set colons=%%x%%x
for %%x in (c C) do if (%1)==(/%%x) goto CLEAR
set program=%1 %2 %3 %4
ver|date>temptemp.bat
echo %0 %%1 %%2 %%3 %%4>current.bat
temptemp
:GOTIT -----------------------------------------------------------------
set date=%4
find /c "%colons%%4%program%" C:\BAT\%0.BAT>temptemp.bat
echo set current=%%2>--------.bat
call temptemp.bat
if (%current%)==(0) echo %colons%%date%%program%>>C:\BAT\%0.BAT
if (%current%)==(0) goto DO_IT
echo Command: %program%
echo has already been run today.
goto CLEANUP
:DO_IT -----------------------------------------------------------------
cls
echo Issuing command: %program% ...
echo.
call %program%
goto CLEANUP
:CLEAR -----------------------------------------------------------------
type C:\BAT\%0.BAT|find /v "%colons%">C:\BAT\%0.BAT
:CLEANUP ---------------------------------------------------------------
for %%x in (-------- temptemp current) do if exist %%x.bat del %%x.bat
for %%x in (program colons current date) do set %%x=
goto END
:SYNTAX ----------------------------------------------------------------
cls
echo.
echo Name: ONCEADAY.BAT
echo.
echo Author: Vernon Frazee 03/03/94
echo.
echo Purpose: Run specified command only once a day.
echo.
echo Syntax: ONCEADAY program_name/command [parm_1] [parm_2] [parm_3]
echo.
echo ONCEADAY /C clears all entries
echo.
echo ONCEADAY /? displays this help
echo.
echo Example: ONCEADAY DEFRAG C: /F /SN
echo.
echo Notes: Requires DOS's FIND (must be available in current PATH)
echo.
echo Requires at least approx 50 bytes free environment space
echo.
echo ONCEADAY.BAT is self modifying! (It keeps track of when
echo and what was run at the end of the file).
echo.
goto END
:END (Data storage begins below) --------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 390 Date: 04 Mar 96 21:52:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: Counting file lines
──────────────────────────────────────────────────────────────────────────────
LD>> I want this batch to make a list of %1 <EG: *.bat or *.txt>
LD>> then use the list to count the lines in each found
LD>> then report to some file, the found file name(s) and the # of
lines
LD>> EG: somefile.txt 27
LD>> othrfile.txt 13
LD>> yetnothr.txt 29
I used SORT and FIND from DOS, and Michael Mefford's CHANGE.COM in the
following batch file to group extension_requested files of the current
directory in a list and count their lines.
After running this file 12 times, you'll get a file creation error on
the 13th run. Anybody know why? Something with the FIND command
or FOR IN DO or CALL? My el cheapo 486?
If I change the do find in the for-in-do to do call find, it bombs on
the 9th try.
REM countext.bat
@echo off
if "%1"== "" goto syntax
set fn=-%1
if exist $!&)list del $!&)list
for %%x in (*.%1) do find /c /v "<^>#~" %%x >>$!&)list
call change $!&)list 13,10,45,45,45,45,45,45,45,45,45,45 "" > nul
call change $!&)list ":" "" > nul
call sort < $!&)list > %fn%list
del $!&)list
set fn=
goto end
:syntax
echo.
echo enter countext ext of filenames you want linecounts of
echo example - countext txt, or countext doc, or countext bat, etc.
echo filenames and linecounts will be in file -extlist
:end
::---------------RCR--------------
Part 1
-!- PCBoard (R) v15.22 (OS/2) 10
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 391 Date: 04 Mar 96 21:54:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: Counting file lines
──────────────────────────────────────────────────────────────────────────────
Here is another version named extcount.bat using PREFIX.COM
from DOSWORLD magazine.
@echo off
if not "%4"== "" goto wrapitup
if "%1"== "almost_done" goto shrink
if "%1"== "" goto syntax
set fn=-%1
if exist $!&)list.bat del $!&)list.bat
if exist %fn%list del %fn%list
for %%x in (*.%1) do call %0 almost_done %%x
call sort < %fn%list > po-trait
del %fn%list
ren po-trait %fn%list
for %%y in (fn name) do set %%y=
goto end
:wrapitup
echo %name% %4 >> %fn%list
if exist $!&)list.bat del $!&)list.bat
goto end
:shrink
set name=%2
echo. | find /c /v "<^>#~" %name% | find "----------" | ...
... prefix extcount plop >>$!&)list.bat
call $!&)list
goto end
:syntax
echo enter extcount and extension of files you want individual count of
:end
::---------------RCR--------------
In extcount.bat, assemble the two lines with ... together at that point
Here is the PREFIX.SCR to DEBUG < PREFIX.SCR to obtain prefix.com
N PREFIX.COM
A
PUSH CS
POP DS
MOV DX,0157
MOV [0155],DX
MOV AH,3F
MOV BX,0000
MOV CX,0001
MOV DX,[0155]
INC WORD PTR [0155]
INT 21
CMP AX,0000
JNZ 0125
MOV AX,4C00
INT 21
PUSH DX
POP SI
MOV AH,[SI]
CMP AH,0A
JZ 0130
JMP 0109
PUSH AX
MOV BX,0001
XOR CH,CH
MOV CL,[0080]
MOV DX,0081
MOV AH,40
INT 21
MOV AH,40
MOV BX,0001
MOV CX,[0155]
SUB CX,0157
MOV DX,0157
INT 21
JMP 0102
RCX
155
W
Q
Try, for example; DIR |prefix put me first >> zzz
Part 2
-!- PCBoard (R) v15.22 (OS/2) 10
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 392 Date: 04 Mar 96 21:55:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: COUNTING FILE LINES
──────────────────────────────────────────────────────────────────────────────
This will count the lines in one file. Submitted to see how badly
Vernon Frazee will "in my face" me with his faster two-liner. But
I do honor the king.
@echo off
if "%2"=="felines" goto felines
if "%1"=="" goto namepls
set fn=%1
find /c /v "<^>#~" %1 > (^^--^^).bat
call change (^^--^^).bat 13,10,45,45,45,45,45,45,45,45,45,45 "felines
felines felines" > nul
echo.
(^^--^^) > nul
:felines
echo file %fn% has %4 lines
goto end
:namepls
echo proper syntax is felines filename
echo this finds # of lines in named file
:end
set fn=
del (^^--^^).bat
-!- PCBoard (R) v15.22 (OS/2) 10
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 424 Date: 05 Mar 96 09:17:01
From: Vernon Frazee Read: Yes Replied: No
To: Stephan Hoppe Mark:
Subj: Get date?
──────────────────────────────────────────────────────────────────────────────
SH> What I'd like to do is have a plain vanilla batch file that grabs
SH> the day of the month so that on the 3rd, for example, I could defrag
SH> my HD, on the 4th run scandisk, etc. etc.
SH> I figure it would have to be something that grabs the day of the
SH> month as an env variable then the calling batch files would check
SH> this to see if its the right day.
SH> How to grab the variable?
SH> Please no 4dos, ndos or whatever. . .just MS-DOS.
Here's one way to get the current system Month, Day, and Year, into
separate environment variables (evars) using DOS's CHOICE.COM.
@echo off
:---------------------------------------------------
: Name: MDY.BAT - For US DATE format (mm-dd-yyyy)
: Purpose: Using current system date, put 2-digit
: month in evar MM, 2-digit day in evar DD,
: and 2-digit year in evar YY.
:Requires: CHOICE.COM and 36 bytes in environment.
:---------------------------------------------------
if (%1)==(![) goto ParseIt
for %%x in (mm dd yy mdy) do set %%x=
>~tmp~.bat ver|date
echo set mdy=%%4>current.bat
for %%x in (call del) do %%x ~tmp~.bat
del current.bat
>~tmp~.bat echo;;|choice/c:;%mdy%; "%0 !"
~tmp~.bat
:ParseIt -------------------------------------------
set mm=%2%3|set dd=%5%6
shift|shift
set yy=%8%9|echo MM=%mm%
echo DD=%dd%
echo YY=%yy%
del ~tmp~.bat|set mdy=
:End ----------------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 428 Date: 05 Mar 96 03:38:00
From: Vernon Frazee Read: Yes Replied: No
To: Richard Dale Mark:
Subj: Humongous project
──────────────────────────────────────────────────────────────────────────────
RD> M:\USERS\74801000>fwcopy 74801000 phone.001
VF> The enclosed examples should help you get started
RD> I thank you very kindly! I shall let you know on the results.
You're more than welcome, and yes, please do.
RD> FWIW, "fwcopy" copies the files over to be used by the Ft. Worth
RD> office, hence "fw". The command that is *really* supposed to be
RD> used is CLEAN 74801000 PHONE.001, but if I mess up and clean
RD> PHONE.001 again within 5 minutes or so, it can crash or slow down
RD> the system. Sheesh!<tm>.
The following might help solve that particular problem. It only
allows the exact same command to be run once per day.
@echo off
:ONCEADAY.BAT runs a specified program once-a-day only -----------------
:Notes: This BATch file is self modifying! It keeps track of every date
: and the command(s) issued on that date at end of this file.
: Requires DOS's FIND (somewhere in current PATH is fine).
: Use "CURRENT /C" (not the quotes) to clear all dates from file.
:-----------------------------------------------------------------------
if (%1%2)==(dateis) goto GOTIT
if (%1)==(/?) goto SYNTAX
if (%1)==() goto SYNTAX
for %%x in (:) do set colons=%%x%%x
for %%x in (c C) do if (%1)==(/%%x) goto CLEAR
set program=%1 %2 %3 %4
ver|date>temptemp.bat
echo %0 %%1 %%2 %%3 %%4>current.bat
temptemp
:GOTIT -----------------------------------------------------------------
set date=%4
find /c "%colons%%4%program%" C:\BAT\%0.BAT>temptemp.bat
echo set current=%%2>--------.bat
call temptemp.bat
if (%current%)==(0) echo %colons%%date%%program%>>C:\BAT\%0.BAT
if (%current%)==(0) goto DO_IT
echo Command: %program%
echo has already been run today.
goto CLEANUP
:DO_IT -----------------------------------------------------------------
cls
echo Issuing command: %program% ...
echo.
call %program%
goto CLEANUP
:CLEAR -----------------------------------------------------------------
type C:\BAT\%0.BAT|find /v "%colons%">C:\BAT\%0.BAT
:CLEANUP ---------------------------------------------------------------
for %%x in (-------- temptemp current) do if exist %%x.bat del %%x.bat
for %%x in (program colons current date) do set %%x=
goto END
:SYNTAX ----------------------------------------------------------------
cls
echo.
echo Name: ONCEADAY.BAT
echo.
echo Author: Vernon Frazee 03/03/94
echo.
echo Purpose: Run specified command only once a day.
echo.
echo Syntax: ONCEADAY program_name/command [parm_1] [parm_2] [parm_3]
echo.
echo ONCEADAY /C clears all entries
echo.
echo ONCEADAY /? displays this help
echo.
echo Example: ONCEADAY DEFRAG C: /F /SN
echo.
echo Notes: Requires DOS's FIND (must be available in current PATH)
echo.
echo Requires at least approx 50 bytes free environment space
echo.
echo ONCEADAY.BAT is self modifying! (It keeps track of when
echo and what was run at the end of the file).
echo.
goto END
:END (Data storage begins below) --------------------------------- -vjf-
RD> Thanks again.
No problem. Let me know how you make out.
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 430 Date: 06 Mar 96 18:32:00
From: Vernon Frazee Read: Yes Replied: No
To: Larry Kwiatkowski Mark:
Subj: Caps in ENV
──────────────────────────────────────────────────────────────────────────────
WE> you need a lot of if-statements to ask for all possiblities ...
WE> set variable=example
WE> set variable=Example
WE> set variable=EXAmple
WE> It would be much easier if I could change the content of an
WE> environment variable to either small or capital letters.
LK> I use a rather complicated routine to do exactly that - map the file
LK> names to all caps - using GET.EXE and QEDIT. I hope there is some
LK> simpler way to accomplish mapping to all caps. Does anyone have a
LK> workable solution?
Here's a fairly simple "COMMAND.COM only" example:
@echo off
:---------------------------------------------------
:UP-CASE.BAT - UPPERcases user parameters
: (up to about 49 characters)
: For example: up-case WiLe e cOyOtE
: returns: WILE E COYOTE
: Note: Results stored in evar UP-CASE
:---------------------------------------------------
if (%1)==() goto End
path>~savpath.bat
for %%x in (up-case path) do set %%x=
:Loop ----------------------------------------------
path %1
if not (%up-case%)==() set up-case=%up-case% %path%
if (%up-case%)==() set up-case=%path%
shift
if not (%1)==() goto Loop
echo %up-case%
for %%x in (call del) do %%x ~savpath.bat
:End ----------------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 402 Date: 08 Mar 96 23:14:04
From: Dennis Mccunney Read: Yes Replied: No
To: Greg Paksi Mark:
Subj: Two OS's on one drive?
──────────────────────────────────────────────────────────────────────────────
** From Greg Paksi to Brian Altenpohl on 29 Feb 96 16:53:54
** Re: Two OS's on one drive?
BA> Also, you may want to take a look into QNX, it is a great O/S, and
BA> comes with the QNX loader, which will allow you up to 4 different OSs
BA> on a single machine. Perhaps newer version of QNX will allow more.
BA> Or you could write a simple Boot-Manager program - it isn't very
GP> What's QNX? How is it different than DOS, UNIX, OS/2, WINDOWS NT,
GP> etc.?
QNX is an operating system from a company in Canada called QNX
(formerly known as Quantum). It began as a UNIX-like OS optimised to
run on Intel CPUs (and would run reasonably on XTs and well on ATs).
It has evolved into an OS aimed at the real-time market, with built-in
network awareness.
-!- Blue Wave/DOS v2.30
! Origin: * BlueDog BBS * (212) 594-4425 * NYC FileBone Hub (1:278/304)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Local Date: 11 Mar 96 18:30:57
From: Bat Lang Read: Yes Replied: No
To: Steve Meech Mark:
Subj: Copying files
──────────────────────────────────────────────────────────────────────────────
-=> Quoting Steve Meech to All, [09 Mar 96 00:29:06] <=-
SM> Anyway, back on topic, the problem is that I have to transfer 13Mb of
SM> files, many of which don't change from one day to the next.
SM> Is there a way of copying only those files which are _different_ on
SM> the two machines, to save time (in the way PKZIP's "update" function
SM> does).
SM> I'd be interested in a batch-file or utility solution.
^^^^^^^^^^^^^^^^^^^
There is a nifty util in the BFDS files called DIRCOMP:
DIRCO511.ZIP 117060 12-18-95 DIRCOMP.EXE (5.11): Updates files in one
subdirectory based on files in another
subdirectory. Similar in some ways to DOS's
REPLACE command
Here is a batch file I use with this to maintain a portable
parallel-port hard drive (Gator) as a mirror of another drive on my
system.
::UPD.BAT to compare two dirs, and kill dir2 files not in dir1 & copy
:: dir1 files to dir2 that are more recent, or not in dir2.
@echo off
CP /T:N,10 Do you want the Gator UpDated?
if %EL% 2 goto end
dirco k: l: /KILL /APPEND /-I
:end
Saves me MANY hours each month, and hasn't messed up yet. Also
maintains a log of it's activities. The second line uses Chad's Choice
Plus (CP102). Could use CHOICE or leave it out.
Note: The %EL% is a shortcut allowed by my inclusion of:
SET EL=ERRORLEVEL ;in my AEBat file.
If your DOS includes REPLACE, you might get it to do your bidding?
I also renamed the DIRCOMP.EXE so it looks like the archive name.
Good Modeming! /\oo/\
... NetMail: 1:382/1201 or E-mail: bat.lang@1201.ima.infomail.com
-!- Blue Wave/Max v2.30
! Origin: The HUB * Austin TX * Centex PCUG * 512-346-1852 (1:382/1201)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 11 Mar 96 12:47:00
From: Gottfried Hommon Read: Yes Replied: No
To: STEPHAN HOPPE Mark:
Subj: Sloppy batch file
──────────────────────────────────────────────────────────────────────────────
----------------------------------------- Vienna, the 11.Mar.1996 at 12.46
Hi STEPHAN!
29-Feb-96 19:35, STEPHAN HOPPE wrote to ALL
Subject: Sloppy batch file
SH> Is there any way of making this a little less bulky?
>>>>>GETDAY.BAT
SH> @echo off
SH> REM the line below returns the day of the month as an errorlevel. . .
SH> c:\utility\1tellme.exe day
SH> if errorlevel 1 if not errorlevel 2 set Today=1
SH> if errorlevel 2 if not errorlevel 3 set Today=2
SH> .
SH> if errorlevel 31 if not errorlevel 32 set Today=31
^^^^^^^^^^^^^^^^^^^^
is not necessary
do this:
for %%f in (1 2 3 4 5 6 7 8 9 10 11 12 13) do if errorlevel %%f set Today=%%f
for %%f in (14 15 16 17 18 19 20 21 22 23) do if errorlevel %%f set Today=%%f
for %%f in (24 25 26 27 28 29 30 31) do if errorlevel %%f set Today=%%f
with friendly greetings
from Gottfried Hommon
-!- Terminate 1.50/Pro
! Origin: ---------------> NOVELL DOS 7.15 USER <--------------- (2:310/65.78)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 12 Mar 96 05:49:03
From: Vernon Frazee Read: Yes Replied: No
To: Scott Farrell Mark:
Subj: File_id.diz
──────────────────────────────────────────────────────────────────────────────
MC> Check a zip file to see if it has a file_id.diz. if not then open
MC> the editor (ide.exe) which produces a file_id.diz in its own
MC> directory then this has to be inserted in the zip that was
MC> checked. If the file has a file_id.diz then continue to check the
MC> next zip.
SF> Have you got a solution to this?
Stick the following simple BATch file in some directory in
your PATH. (I keep my BATch files in "C:\BAT" for example).
@echo off
:ZIPID.BAT
pkunzip %1 file_id.diz
if errorlevel 11 goto End
edit file_id.diz
pkzip %1 file_id.diz
del file_id.diz
:End
Now change to the drive:\directory containing the ZIP files you
want to work on and type the command:
for %x in (*.zip) do call zipid %x
That's it.
Each ZIP file in your current directory will be checked for the
presence of a FILE_ID.DIZ file. If it exists, ZIPID.BAT file simply
exits (and then the for-in-do command above re-launches it with a
new filename.ZIP). If a FILE_ID.DIZ didn't exist, DOS EDIT is
launched so you can create one. When you exit EDIT, PKZIP adds your
new FILE_ID.DIZ to the filename.ZIP file just checked, your
FILE_ID.DIZ is deleted, and ZIPID.BAT exits back to DOS. And, when
the for-in-do is done presenting all the filename.ZIPs to ZIPID.BAT,
all your ZIP files should contain a FILE_ID.DIZ.
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 13 Mar 96 9:49:00
From: Horst Schaeffer Read: Yes Replied: No
To: Paul Emmons Mark:
Subj: Scripting programs
──────────────────────────────────────────────────────────────────────────────
-=> quoting Paul Emmons to All (7 Mar 96) <=-
PE> [...]
PE> Could anyone describe the basic techniques or algorithms which
PE> these various systems use?
-+-+- quote from Richard Marks' UUencode/UUdecode package:
The basic scheme is to break groups of 3 eight bit characters (24 bits)
into 4 six bit characters and then add 32 (a space) to each six bit
character which maps it into the readily transmittable character.
Another way of phrasing this is to say that the encoded 6 bit
characters are mapped into the set:
`!"#$%&'()*+,-./012356789:;<=>?@ABC...XYZ[\]^_
for transmission over communications lines.
As some transmission mechanisms compress or remove spaces, spaces are
changed into back-quote characters (a 96). (A better scheme might be
to use a bias of 33 so the space is not created, but this is not done.)
Another newer less popular encoding method, called XX-encoding uses the
set: +-01..89ABC...XYZabc...xyz
In my opinion, XX-encoding is superior to UU-encoding because it uses
more "normal" characters that are less likely to get corrupted. In
fact several of the special characters in the UU set do not get thru an
EBCDIC to ASCII translation correctly.
-+-+- unquote
PE> 256^4 = 4.294968E+09, and 85^5 = 4.437053E+09. Therefore, four
PE> binary bytes could be encoded into five ascii characters using any
PE> 85 of the ascii values between 32 and 127. Although I haven't
PE> tried implementing this in assembler, I would guess that
PE> recovering the original binary file from such a script would fit
PE> the architecture and instruction set of the 86 processors easily,
PE> i.e. the necessary code could be given in a short enough debug
PE> script header.
For a range of 85 you would need 32 bit multiplications. No big problem
even for a 8086, but the DEBUG header will become a little larger.
Main problem is to define a set of 85 characters that is safe enough
for FIDO mails. I'm not sure which characters between 31 and 127 have
to be definitely excluded to avoid problems.
PE> Probably others have thought of this principle or a better one, so
PE> there is no point in re-inventing the wheel if it has been done. I
PE> would like to know how Chad's and Horst's encoding systems work,
PE> but the answer is not obvious from the scripts they produce.
I think everyone used the simple method of shifting 4*6 bits out of
24. The idea of using a range other than 2^n is a very interesting
approach indeed.
However a ratio of 5/3 (vs. 4/3) would make scripts only 6.25% smaller
(not counting the overhead), and in zipped mail packages it will
probably make no difference at all.
Is is worth introducing a new standard?
Horst.
... Q4FM 2.10 ... horst@confusion.rmc.de
-!- FM 2.02 / ScanToss
! Origin: Don't follow leaders! (2:2480/13.75)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 429 Date: 12 Mar 96 22:41:00
From: William Lipp Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Sloppy Batch
──────────────────────────────────────────────────────────────────────────────
-=> Quoting Larry Nelson to William Lipp <=-
LN> for %%q in (1 2 3) do if errorlevel %%q goto %%q
LN> When I reversed the order of the options in For's set to
LN> (3 2 1) the result was always 1
LN> Any body got an idea why For needs the options in asending
LN> order rather than desending?
The behavior of for-in-do with goto was a topic of discussion a few
months back. My recollection is that the loop finishes all iterations
before executing any "goto" statement. It then acts upon the
last goto.
___ Blue Wave/QWK v2.12
-!- Maximus 3.01
! Origin: this space available bbs (1:141/1111)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 424 Date: 13 Mar 96 20:48:00
From: Vernon Frazee Read: Yes Replied: No
To: Dennis Mccunney Mark:
Subj: Batch Problem
──────────────────────────────────────────────────────────────────────────────
DM> Are you telling 4DOS to load itself and its environment and aliases
DM> into UMBs? There are an assorment of directives settable in
DM> 4DOS.INI to specify this:
DM> UMBAlias Load global aliases in UMB
DM> UMBDirHistory Load global directory history in UMB
DM> UMBEnvironment Load master environment in UMB
DM> UMBHistory Load history in UMB
DM> UMBLoad Load resident part of 4DOS in UMB
DM> Do so, and your environment and other things 4DOS uses come out of
DM> conventional memory, as does all but 256 bytes of the resident
DM> portion of 4DOS itself)
DM> I strongly suspect the memory values you posted above would be
DM> rather different if you did this.
As suggested I created a 4DOS.INI file containing the following:
UMBAlias
UMBDirHistory
UMBEnvironment
UMBHistory
UMBLoad
From "mem/c" before creating 4DOS.INI ------------------------------
Free 747,616 (730K) 635,200 (620K)
From "mem/c" after after creating 4DOS.INI -------------------------
Free 747,616 (730K) 635,200 (620K)
What am I doing wrong?
VF> Hmmm... With just a 360K disk, the tools I would probably grab would
VF> be everything I might need to format a hard drive: DEBUG, FDISK, and
VF> FORMAT (68,020 bytes); a few general tools like: CHKDSK, CHOICE,
VF> EDLIN, and FIND (33439 bytes); of course GWBASIC (80,592 bytes); and
VF> then my communications program {COMMO} (29,872 bytes) so I could
VF> logon to any one of a multitude of systems I have access to and
VF> download anything else I might need. <g> On a MS-DOS v6.22 bootable
VF> diskette that should still leave over 10,000 bytes for whatever
VF> else.
DM> You don't compress the executables?
Not usually, no.
DM> You can't do it to COMMAND.COM, but everything else will pack down
DM> nicely.
DEBUG.EXE, FORMAT.COM, and CHKDSK.EXE already come compressed
but yes, packing the others (PKLITE) reduced overall size by
almost 11%. Good idea, thanks!
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 440 Date: 13 Mar 96 20:48:12
From: Vernon Frazee Read: Yes Replied: No
To: Phi Nguyen Mark:
Subj: write to start of text fi
──────────────────────────────────────────────────────────────────────────────
PN> ---------PREPEND.BTM------------------
PN> @*echo off
PN> *if %# lt 2 goto Syntax_Error
PN> *setdos /x-1
Vf> [ ... 46 lines deleted ... ]
PN> ---------------------------------------
Here's a simple example that works with DOS:
@echo off
:PREPEND.BAT
if (%2)==() goto End
if not exist %1 goto End
set ~fn=%1
copy %~fn% ~1>nul
:Loop
shift
if (%1)==() goto Copy
if not (%~tx%)==() set ~tx=%~tx% %1
if (%~tx%)==() set ~tx=%1
goto Loop
:Copy
echo %~tx%>~2
copy ~2+~1 %~fn%>nul
for %%x in (1 2) do del ~%%x
for %%x in (fn tx) do set ~%%x=
:End
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 15 Mar 96 17:58:01
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Sloppy Batch
──────────────────────────────────────────────────────────────────────────────
JK> for %%a in (1 2 3 4 5 6 7 8 9..... 31) do if errorlevel %%a .....
JK> (A classic .BAT improvement!)
WL> Since the errorlevel function is "errorlevel greater than or equal
WL> to N", this code would execute the "if" section 31 times for a
WL> "no error" return of zero. That was probably not what you had in
WL> mind.
LN> For seems to tweak the order of things. Joe's example worked fine
LN> for me when I use it as in the following....
LN> ::4tst.bat/DOS62.0
LN> @echo off
LN> cls
LN> choice/cabc
LN> for %%q in (1 2 3) do if errorlevel %%q goto %%q
LN> :1
LN> echo a
LN> goto L8r
LN> :2
LN> echo b
LN> goto L8r
LN> :3
LN> echo c
LN> :L8r
LN> When I reversed the order of the options in For's set to (3 2 1) the
LN> result was always "a" Any body got an idea why For needs the options
LN> in asending order rather than desending?
Because DOS will process everything in between the parenthesis
before it makes it's final descision.
For example, with (1 2 3) and you press B, DOS will do:
if errorlevel 1 goto 1 (which proves true)
if errorlevel 2 goto 2 (which proves true)
if errorlevel 3 goto 3 (which proves not true)
Now that it's done testing it does the last thing that proved true,
"goto 2", which is correct.
But if you flip it around, (3 2 1), and press B, DOS will do:
if errorlevel 3 goto 3 (which is not true)
if errorlevel 2 goto 2 (which is true)
if errorlevel 1 goto 1 (which is true)
Now that it's done testing it does the last thing that proved true,
"goto 1", which is incorrect.
Clear as mud yet? <G>
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 16 Mar 96 08:01:00
From: David Roper Read: Yes Replied: No
To: Vernon Frazee Mark:
Subj: BATCH PROBLEM
──────────────────────────────────────────────────────────────────────────────
VF> Hmmm... With just a 360K disk, the tools I would probably grab would
VF> be everything I might need to format a hard drive: DEBUG, FDISK, and
VF> FORMAT (68,020 bytes); a few general tools like: CHKDSK, CHOICE,
VF> EDLIN, and FIND (33439 bytes); of course GWBASIC (80,592 bytes); and
VF> then my communications program {COMMO} (29,872 bytes) so I could
VF> logon to any one of a multitude of systems I have access to and
VF> download anything else I might need. <g> On a MS-DOS v6.22 bootable
VF> diskette that should still leave over 10,000 bytes for whatever
VF> else.
VF> DEBUG.EXE, FORMAT.COM, and CHKDSK.EXE already come compressed
> but yes, packing the others (PKLITE) reduced overall size by
> almost 11%. Good idea, thanks!
Vernon, if you're trying to shrink 'em (and I have a similar disk to
yours for traveling) I used the COMTOEXE and then LZEXE so that I
didn't have to buy PKLITE. Nothing wrong with buying PKLITE, but
for those reading this message, there's the other way "out."
_____oOOo_/00\_oOOo_____ david.roper@mms.raleigh.nc.us
1996 \__/ 201 WINDING BROOK Dr, GARNER NC 27529
-!- FLAME v1.1
! Origin: Full Internet Access $15.00, (919) 779-6674 or MMS.NET (1:151/102)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 17 Mar 96 15:27:05
From: Stamatis Kantartzis Read: Yes Replied: No
To: Jim Danvers Mark:
Subj: Prompt
──────────────────────────────────────────────────────────────────────────────
Hi Jim! What's up?
On 16-Mar-96, at 09:23:00, Jim Danvers wrote this to All about Prompt:
JD> Hi guys... I would like to get a "spinning wheel" type
JD> prompt for command lines. IE;, a spinning | symbol... can we do
JD> this through ansi? That's all.... call me bored. <g>
Here's the latest version of SPIN.BAT:
@echo off
loadbtm on
setlocal
::-----Init spinning characters
set s0=`%=|`
set s1=/
set s2=-
set s3=\
::-----Init pointer to starting position
set s=0
:-----Save cursor
set cursor=%_CO:%_CI
::-----This is for olders version of 4DOS
if "%cursor" eq ":" set cursor=10:100
::-----Turn off cursor
setdos /s0:0
::-----Display title
echo %=nSPIN.BAT - Phi Nguyen 03.04.96%=n
echo Press any key to quit%=n
::-----Display prompt. It requires 2 trailing spaces (1 will be erased)
echos `Please wait: `
do while %_kbhit eq 0
::-----Display spin
:: %=b uses to clear the previous spin char (backspace)
:: %[s%s] uses to show the current spin char (like *ptr in C)
echos %=b%[s%s]
::-----Increase the pointer to next spin char. It will rotate from
:: 0 to 3 to 0 to 3 ...
set s=%@word[%s,1 2 3 0]
::-----Do whatever here
enddo
::-----Clear prompt
echos %=r %=r
::-----Eat keypressed
inkey %%key
::-----Turn on cursor
setdos /s%cursor
endlocal
|-=-=-=> Sincerely, Stamatis Kantartzis <=-=-=-|
.!. Inflation means the Buck does not stop here...
-!- Terminate 3.00
! Origin: (1:109/570.14)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 430 Date: 21 Mar 96 00:16:11
From: Paul Emmons Read: Yes Replied: No
To: Jeff Dubois Mark:
Subj: zipping gazillions of tex
──────────────────────────────────────────────────────────────────────────────
-> Is there a simply way, via batch, to zip up a gazillion *.TXT files
-> into individual zip files and upon completion then delete all the
-> *.TXT files in that directory?
->
-> What I got: A.TXT, B.TXT, C.TXT ...
-> What I want: A.ZIP, B.ZIP, C.ZIP ...
->
-> There is an easy way. But I don't know it. :-)
I think the best way is to create a subdirectory to receive the
zip files, or at least put them in a subdirectory which has no
files *.txt. If this subdirectory is \TEM, then you need:
for %%f in (*.txt) do pkzip -omex \tem\%%f %%f
ren \tem\*.txt *.zip
The pkzip -m flag will remove the files it zips up. The files
created by pkzip in \tem are originally named *.txt, and you
have to rename them *.zip in a separate line.
-!- FidoPCB v1.4 [ff348/b]
! Origin: The Bauding House (1:2626/312) 610/692-7392
─ Area: Batch Language Programming FI ────────────────────
Msg#: 450 Date: 23 Mar 96 23:45:00
From: Gary Smith Read: Yes Replied: No
To: Jeff Dubois Mark:
Subj: zipping gazillions of tex
──────────────────────────────────────────────────────────────────────────────
JD> Is there a simply way, via batch, to zip up a gazillion *.TXT files into
> individual zip files and upon completion then delete all the *.TXT files in
> that directory?
JD> What I got: A.TXT, B.TXT, C.TXT ...
> What I want: A.ZIP, B.ZIP, C.ZIP ...
JD> There is an easy way. But I don't know it. :-)
The following is fairly straightforward. It assumes that you're
running it in the directory where the TXT files reside, and does
no error checking. If you like lots of activity on the screen,
remove the two occurrences of "> nul".
@echo off
md $$temp$$
for %%f in (*.txt) do pkzip -m $$temp$$\%%f %%f > nul
ren $$temp$$\*.txt *.zip
move $$temp$$\*.zip . > nul
rd $$temp$$
-!-
* OLX 1.53 * Veni, vidi, velcro - I came, I saw, I stuck around
-!- WILDMAIL!/WC v4.12
! Origin: The Computer Room-Pickerington, Oh (1:226/110.0)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 26 Mar 96 17:25:02
From: Vernon Frazee Read: Yes Replied: No
To: Roy Reed Mark:
Subj: J. Dubois request, others complaints
──────────────────────────────────────────────────────────────────────────────
RR> I tried a quick and dirty way to convert .txt files to .zip files
RR> per request of Mr. Dubois. Per response of Mr. Primus, this method
RR> did not retain the .txt extension within the zipped file. Per Mr.
RR> Frazee's response, extensionless files in the directory were not
RR> protected. Per this response, the batch file below handles said
RR> complaints. It's just not as cheap and dirty as original. For Mr.
RR> Fraley, I truncated the .txt so that the pkzip command in the
RR> FOR-IN-DO would zip the file and give it the same name, which
RR> resulted in loss of extension inside the .zip file.
RR> I love doing this to get Frazee cranking - hehehehehe.
Guess who? <G>
RR> -!---upper extraction line-----
RR> @echo off
RR> if "%1"=="blasphemy" goto blasphemy
RR> ren *. *.^-^
RR> ren *.txt *.
RR> for %%x in (*.) do call %0 blasphemy %%x
RR> del *.txt
RR> ren *.^-^ *.
RR> set base=
RR> goto end
RR> :blasphemy
RR> set base=%2
RR> ren %2 %2.txt
RR> pkzip %2 %2.txt
RR> :end
RR> -!---lower extraction line-----
Here, try this ZIP&DEL.BAT
@echo off
>~tmptmp~.bat mode %1
>invalid.bat echo set ~fn~=%%3
for %%x in (call del) do %%x ~tmptmp~.bat
pkzip -exmo %~fn~% %1 | del invalid.bat
To use it, first make sure you the above ZIP&DEL.BAT, DOS's MODE.COM
and Phil Katz' PKZIP.EXE in your PATH (or current directory) and at
least 18 bytes free environment space.
Now go to some directory containing at least a few files with the
same extension, for example ".TXT", and then type the command:
for %x in (*.txt) do call zip&del %x
That's it. When this four-working-line "ZIP&DEL.BAT" gets done:
a) all the *.TXT files will each be in their own individual
"samename.ZIP" file
b) with a date and time stamp matching the original file
c) and the originals deleted.
"Kewl" eh? <G>
Now give me something to "crank" on. That may have taken the better
part of maybe a minute to whip up using nothing more than "COPY CON"
a-n-d it required no further editing. <grin>
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate = Pointmailer+Tosser+Reader+Packer+QWK! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 449 Date: 27 Mar 96 03:05:37
From: Dennis Mccunney Read: Yes Replied: No
To: Otto Lang Mark:
Subj: PATH limit
──────────────────────────────────────────────────────────────────────────────
** From Otto Lang to Dennis McCunney on 24 Mar 96 16:30:00
** Re: PATH limit
DM> JC> Well, some of us STILL use only DOS. Like me. I use a menu program,
DM> JC> but I also do things from the DOS prompt and from a File Manager
DM> JC> program. Therefore, I have a fairly long path. Witness:
DM> JC> Path C:\;C:\DOS;C:\UTIL\TV;C:\UTIL\PAK;C:\3DMENU;C:\WP60;
DM> JC> Path %PATH%;C:\UTIL\PGP;C:\UTIL\UUCODE;C:\SOUND\UTIL\DAPLAY;
DM> I still use only DOS here, as well, but I'm at pains to keep my PATH
DM> short. The current one is:
DM> PATH=e:\;c:\usr\batch;c:\usr\vdisk;c:\usr\bin;c:\4dos;c:\usr\lbin;c:\dos;
DM> c:\bin;c:\dgn;..;.
OL> There are two lesson I learned early: (1) Keep dir names short, e.g.
OL> UT or UTL instead of UTIL and (2) if you SUBST U: C:\USR you can save
OL> a lot of typing and see more of your path line in the autoexec.bat.
OL> Just don't forget the LASTDRIVE=Z!
The directory names and directory structure I use are based on those
used by UNIX. I learned UNIX before I really spent any time in DOS,
and I find it simpler to make my DOS environment resemble the one I
have under UNIX as much as possible. (With the MKS Toolkit installed,
that can be more than you would believe...) I've never found SUBST
neccessary, and I use LASTDRIVE=E:, since that IS my last drive.
Seeing the long PATH isn't a big problem, since it isn't that long,
and I'm more concerned about the number of directories in it than the
length of the directory names. Directories are in the PATH in the
order of frequency of access. I keep the command processor and some
frequently used utilities on the ramdisk, so that is first in the PATH.
Saving typing is provided by other 4DOS features. I set
environment variables to the names of frequently used directories.
For example, I have UB=c:\usr\bin in my environment definitions. 4DOS
interprets variables on the command line as well as in batch files, so
I can do "p %ub", instead of "pushd c:\usr\bin". P is an alais for
PUSHD, an internal command in 4DOS that pushes the current directory
onto a stack and changes to the drive directory specified as the
argument. POPD (aliased to "." here) pops the saved drive/directory
from the stack and returns me to where I was.
-!- Blue Wave/DOS v2.30
! Origin: * BlueDog BBS * (212) 594-4425 * NYC FileBone Hub (1:278/304)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 27 Mar 96 16:30:48
From: Vernon Frazee Read: Yes Replied: No
To: Roy Reed Mark:
Subj: IS THIS DIRECTORY EMPTY?
──────────────────────────────────────────────────────────────────────────────
RR> I use dos 5 and the following works for me. I use find to pick out
RR> the "2 files and 0 bytes" if a dir is empty. If not, it doesn't
RR> pick out, and a zero length byte file doesn't get copied, which I
RR> check to see if it exists. I heard 4dos copies 0 byte files. Ta
RR> ta.
RR> -!--- snip line-----
RR> @echo off
RR> if "%1"=="/?" goto syntax
RR> dir %1 | find "2 file(s) 0 bytes" > ~~~4now
RR> copy ~~~4now ~~~after > nul
RR> if exist ~~~after echo directory %1 is empty
RR> if not exist ~~~after echo directory %1 contains at least one file
RR> if exist ~~~4now del ~~~4now > nul
RR> if exist ~~~after del ~~~after > nul
RR> goto end
RR> :syntax
RR> echo proper syntax is, for example, isempty c:\utils or
RR> echo isempty c:\write\wp
RR> :end
RR> -!--- snip line-----
You don't really need to use FIND and a temporary file to do the
trick. For example:
@echo off
:CHKDIR - Does it exist? If so, any files?
if (%1)==() echo Syntax: %0 [[d:]\]dirname[\dir[\dir\...]]
if (%1)==() goto End
if not exist %1\nul echo Directory "%1" does not exist.
if not exist %1\nul goto End
if not exist %1\*.* echo Directory "%1" is empty.
if exist %1\*.* echo Directory "%1" has files.
:End
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Get real, get better, get faster, get Terminate! (1:135/71.16)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 27 Mar 96 09:33:30
From: Vernon Frazee Read: Yes Replied: No
To: Tony Johnston Mark:
Subj: unzip files
──────────────────────────────────────────────────────────────────────────────
TJ> Is it possible to have abat or exe file automatically execute just
TJ> after is has been unzipped. If so how?
With a ZIP file, fortunately no. (Makes it to easy for kids to
automatically launch something destructive). Of course there is
nothing stopping you from simply wrapping a BATch file around it:
@echo off
:START.BAT
md c:\whatever
pkunzip whatever.zip c:\whatever
for %%x in (c: cd\whatever whatever cd\) do %%x
:End
Another alternative is to use ARJ instead of PKZIP. For example,
the following single ARJ command will unarchive FOOBAR.BAT from
archive FOOBAR.ARJ and then immediately launch the FOOBAR.BAT:
arj b foobar.arj foobar.bat -jqfoobar.bat
--- - ---------- ---------- ----------
| | | | |
| | | | |
| | | | `-- DOS command to execute after
| | | | the extraction has occurred
| | | |
| | | `-- Name of the file to extract
| | |
| | `-- Name of the ARJ archive to use
| |
| `-- Allow user to execute a DOS command
| on selected file(s) in the archive
|
`-- Launch ARJ.EXE
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate SmartNote: Remembers & recalls everything! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 442 Date: 28 Mar 96 07:31:30
From: Vernon Frazee Read: Yes Replied: No
To: Otto Lang Mark:
Subj: debug or share
──────────────────────────────────────────────────────────────────────────────
OL> ... PPT insists on having SHARE.EXE loaded. I guess because of
OL> Windows' multitasking? Anyway, as soon as I added
OL> INSTALL=C:\DOS\SHARE.EXE to my CONFIG.SYS the next boot hung on
OL> errors in the debug statement in CURRENT.[BAT]. ... Debug ... errors
OL> ... trying to load from ... <temptemp.scr.
OL> :CURRENT.BAT from Fidonet ... BATPOWER. ... Vernon Frazee 01/17/94
I'm getting the same results here -- under DOS v6.22. How about a
newer version, GET-DT.BAT (Get Date and Time), that will not only
work with SHARE loaded, (and/or should run fine under Windows95),
but also sets Day in evar "DY", Month in evar "MM", Day date in evar
"DD", Year in evar "YY", Hour in evar "HR", Minute in evar "MN", and
Second in evar "SC"?
:GET-DT.BAT - Type "GET-DT /?" (not the quotes) for help
:Note: Do NOT put a "@echo off" at the beginning of this file!
:Begin -------------------------------------------------------
@if (%1)==(/?) goto Syntax
@if (%1)==(!!) goto GetMDY
@if (%1)==(!) prompt set dt=!! $d $t
@if (%1)==(!) goto End
@echo off
for %%x in (dt dy mm dd yy hr mn sc) do set %%x=
command /c %0 !>~tmp_01~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
%0 %dt%
:GetMDY ------------------------------------------------------
set dt=
set DY=%2
shift|shift
echo;;|choice /c:;%1%; "~tmp_02~ ">~tmp_01~.bat
echo set mm=%%2%%3>>~tmp_02~.bat
echo set dd=%%5%%6>>~tmp_02~.bat
for %%x in (1 2) do echo shift>>~tmp_02~.bat
echo set yy=%%8%%9>>~tmp_02~.bat
call ~tmp_01~.bat
:GetHMS ------------------------------------------------------
echo;;|choice /c:;%2%; "~tmp_02~ ">~tmp_01~.bat
echo if (%%3)==(:) goto Insert0>~tmp_02~.bat
echo set hr=%%2%%3>>~tmp_02~.bat
echo set mn=%%5%%6>>~tmp_02~.bat
echo set sc=%%8%%9>>~tmp_02~.bat
echo goto End>>~tmp_02~.bat
echo :Insert0>>~tmp_02~.bat
echo set hr=0%%2>>~tmp_02~.bat
echo set mn=%%4%%5>>~tmp_02~.bat
echo set sc=%%7%%8>>~tmp_02~.bat
echo :End>>~tmp_02~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
del ~tmp_02~.bat
:************************************************************:
: To display results, change the next line to "goto Display" :
:************************************************************:
goto End
:Syntax ------------------------------------------------------
@echo off
cls
echo Name: GET-DT.BAT - Get current system Date and Time
echo.
echo Author: Vernon Frazee 06/14/94 - (Last mod: 03/28/96)
echo.
echo Purpose: Store the current system:
echo.
echo Day in evar "DY" (example: DY=Tue)
echo Month in evar "MM" (example: MM=05 )
echo Day date in evar "DD" (example: DD=31 )
echo Year in evar "YY" (example: YY=94 )
echo Hour in evar "HR" (example: HR=06 )
echo Minute in evar "MN" (example: MN=22 )
echo Second in evar "SC" (example: SC=00 )
echo.
echo Syntax: [call] [d:[\path]]GET-DT [/?]
echo.
echo Where: /? displays this help screen
echo.
echo Requires: DOS's COMMAND.COM and CHOICE.COM (somewhere in
echo the PATH is fine), and 43 bytes of free space
echo in the environment.
echo.
echo Note: "evar" is short for "environment variable".
echo.
goto End
:Display -----------------------------------------------------
echo DY=%dy% MM=%mm% DD=%dd% YY=%yy% HR=%hr% MN=%mn% SC=%sc%
:End --------------------------------------------------- -vjf-
(Note: I would normally test this under Windows95 first for you,
but, at the moment I'm at the beach waiting for breakfast to arrive
and tapping away on this DOSv6.22/WFWGv3.11 based Laptop. <g>)
./~ She wore an itsy bitsy teeny weeny yellow polka-dot bikini.. ./~
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: The NEW Terminate will -=> FAX <=- almost anything! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 28 Mar 96 06:07:54
From: Vernon Frazee Read: Yes Replied: No
To: Josef Schwartz Mark:
Subj: how do I...
──────────────────────────────────────────────────────────────────────────────
VF> The following ANSI escape sequence sets the [UpArrow] so it acts
VF> like a press of the [Enter] key: <-[0;72;"";13p
> [snip]
JS> What would I have to do to switch the ";" with the ":" ?
I used to do that too, years ago, and still have customers
occasionally requesting the same. All it really takes is a couple
of escape sequences, (much like the one above), but, instead of
trying to explain how to do ANSI escape sequences, I've simply been
giving them the enclosed SEMISWAP.BAT along with the following
SEMISWAP.BAT Instructions:
1) Place a copy of the enclosed SEMISWAP.BAT in a directory in your
PATH. (For example, in "C:\BAT").
2) Make sure your CONFIG.SYS file has something similar to the
following line in it: DEVICE=C:\DOS\ANSI.SYS
3) Insert the following line near the beginning of your AUTOEXEC.BAT
file: CALL C:\BAT\SEMISWAP.BAT /ON
4) Reboot and get to the DOS prompt.
5) Type "SEMISWAP" (not the quotes) and the current status should be
"SEMISWAP=On". If it is, your ";" and ":" keys should now be
swapped. If not, start back at "1)", making sure sure each and
every character is correct and that the "drive:\path\" on each
line actually points to the respective file. (In other words,
does the ANSI.SYS file actually exist in directory C:\DOS?; etc.)
------------------------------> Cut Here <------------------------------
@echo off
:SEMISWAP.BAT - Swaps the ":" and ";" keys, or resets to normal.
goto ParmCheck
:Syntax ----------------------------------------------------------------
cls
echo Name: SEMISWAP.BAT (Vernon Frazee 03/11/84, Last Mod 03/28/96)
echo.
echo Purpose: Swaps the semi-colon ";" and the colon ":" keys.
echo.
echo "/On" = Swapped and "/Off" = Normal
echo.
echo In other words, when On or swapped:
echo.
echo a) simply pressing the [;] key will now produce the ":"
echo character (instead of having to hold down the [Shift]
echo key and pressing the [;] key to get it).
echo.
echo b) and to get the ";" character, you will now have to
echo hold down the [Shift] key and press [;].
echo.
echo Syntax: [call] [d:][\path]SEMISWAP [/On (or) /Off (or) /?]
echo.
echo SEMISWAP - Display current status
echo SEMISWAP /On - Swap ":" with ";"
echo SEMISWAP /Off - Return ":" and ";" to normal
echo SEMISWAP /? - Display this screen
echo.
echo Requires: DOS' ANSI.SYS (or equivalent) and up to 13 bytes of free
echo environment space. (Evar SEMISWAP=On or SEMISWAP=Off).
goto End
:ParmCheck -------------------------------------------------------------
if (%1)==() goto Display
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
for %%x in (on On ON oN) do if (%1)==(/%%x) goto On
for %%x in (off Off OFf OFF oFF ofF) do if (%1)==(/%%x) goto Off
goto Syntax
:Display status --------------------------------------------------------
if (%SEMISWAP%)==() set SEMISWAP=Off
echo SEMISWAP=%semiswap%
goto End
:On (Swap the ";" and ":" keys) ----------------------------------------
echo [58;59p [59;58p [1A
rem `-------`-------`------- Three [Esc] characters (Alt-27's)
set SEMISWAP=On
goto Display
:Off (Unswap the ";" and ":" keys (back to normal)) --------------------
echo [58;58p [59;59p [1A
rem `-------`-------`------- Three [Esc] characters (Alt-27's)
set SEMISWAP=Off
goto Display
:End ------------------------------------------------------------- -vjf-
------------------------------> Cut Here <------------------------------
6) To view SEMISWAP's brief instructions type: SEMISWAP /?
That's it. Enjoy!
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: The NEW Terminate will -=> FAX <=- almost anything! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 431 Rec'd Date: 01 Apr 96 08:24:39
From: Vernon Frazee Read: Yes Replied: No
To: Bat Lang Mark:
Subj: Echoing redirection chara
──────────────────────────────────────────────────────────────────────────────
VF> Change to the directory containing your SCRipt files and create
VF> the following 1-line "X.BAT":
VF> @debug<%1
VF> Now type the command:
VF> for %x in (*.scr) do call x %x
VF> and all the SCRipt files in the current directory will be
VF> processed by DEBUG.
BL> Vernon, would appreciate a short {^; synopsis that would teach us
BL> all, the set of circumstances that lead to deciding: when it's
BL> better/best to use the FOR...IN...DO from the command line, rather
BL> than including it within a batch file.
BL> I'm sure we will all be grateful for this poop! Thanks, and Good
BL> Modeming! /\oo/\
Hmmm... If it's something that will be used repetitively, I
usually wrap a BATch file around it. For instance, the above
might be _quickly_ thrown together as:
@echo off
:DEBUG'EM.BAT
if (%2)==(~!~) goto DoIt
for %%x in (*.scr) do call %0 %%x ~!~
:DoIt
if (%1)==() goto End
echo %1
debug<%1>nul
:End
The short solution I gave above must have been because it appeared
that the user posing the question needed to do the task but once.
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Have you ever been TERMINATEd ? (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 425 Date: 01 Apr 96 16:51:00
From: TYRIN PRICE Read: Yes Replied: No
To: INGRID DEKKER Mark:
Subj: CHOICE
──────────────────────────────────────────────────────────────────────────────
Hi Ingrid!
ID>Can someone tell me how to use the CHOICE command for more than two options
ID>list the options right behind the number (ie: 1 start anyprogram) without
ID>getting the [Y/N] returned from DOS? Or is it enought to just echo the opti
ID>and set errorlevels without CHOICE?
CHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] [text]
/C[:]choices Specifies allowable keys. Default is YN
/N Do not display choices and ? at end of prompt string.
/S Treat choice keys as case sensitive.
/T[:]c,nn Default choice to c after nn seconds
text Prompt string to display
ERRORLEVEL is set to offset of key user presses in choices.
You could TYPE a text file to the screen or ECHO a menu to the screen
like this...
ECHO 1) Word Processor
ECHO 2) Database
ECHO 3) Spreadsheet
ECHO 4) Telecommunications
And then use CHOICE like this
CHOICE /C1234 /N What'll It Be?
IF ERRORLEVEL 4 TELIX
IF ERRORLEVEL 3 LOTUS
IF ERRORLEVEL 2 DBASE
IF ERRORLEVEL 1 WP
-=Ty=-
* SLMR 2.1a * BREKFAST.COM halted: cereal port not found.
-!- GOMail v2.0 [94-0021]
! Origin: The Home of Aunt Gabby (1:123/17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 444 Date: 01 Apr 96 16:33:00
From: Roy Reed Read: Yes Replied: No
To: Robert Morton Mark:
Subj: Unique filenames
──────────────────────────────────────────────────────────────────────────────
I took a beautiful batch file by Vernon Frazee and butchered it to
get into envars the last digit of the year, one hex letter/number for
the month, two digits for the day, and the total seconds from the
current hour, minute and seconds plus offsetting it in an envar called
addxx. I didn't go to the extent of saving the filename-base in an
envar from %1 for you. Type set to see all. I now know three tips
of Frazee's seven million. Used them here. Never catch that hummer.
Just run it to see the stuff in the environment. You'll need
CHANGE.COM,
CHOICE, GWBASIC, and CHANGE.COM.
---------------- snip ------------------
:MORTON.BAT - Type "MORTON /?" (not the quotes) for help
:Note: Do NOT put a "@echo off" at the beginning of this file!
:Begin -------------------------------------------------------
@if (%1)==(/?) goto Syntax
@if (%1)==(!!) goto GetMDY
@if (%1)==(!) prompt set dt=!! $d $t
@if (%1)==(!) goto plum
@echo off
for %%x in (dt dy mm dd yy hr mn sc) do set %%x=
command /c %0 !>~tmp_01~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
%0 %dt%
:GetMDY ------------------------------------------------------
set dt=
set DY=%2
shift|shift
echo;;|choice /c:;%1%; "~tmp_02~ ">~tmp_01~.bat
echo set mm=%%2%%3>>~tmp_02~.bat
echo set dd=%%5%%6>>~tmp_02~.bat
for %%x in (1 2) do echo shift>>~tmp_02~.bat
echo set yy=%%9>>~tmp_02~.bat
call ~tmp_01~.bat
:GetHMS ------------------------------------------------------
echo;;|choice /c:;%2%; "~tmp_02~ ">~tmp_01~.bat
echo if (%%3)==(:) goto Insert0>~tmp_02~.bat
echo set hr=%%2%%3>>~tmp_02~.bat
echo set mn=%%5%%6>>~tmp_02~.bat
echo set sc=%%8%%9>>~tmp_02~.bat
echo goto End>>~tmp_02~.bat
echo :Insert0>>~tmp_02~.bat
echo set hr=0%%2>>~tmp_02~.bat
echo set mn=%%4%%5>>~tmp_02~.bat
echo set sc=%%7%%8>>~tmp_02~.bat
echo :End>>~tmp_02~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
del ~tmp_02~.bat
:************************************************************:
: To display results, change the next line to "goto Display" :
:************************************************************:
goto End
:Syntax ------------------------------------------------------
@echo off
echo Requires: DOS's COMMAND.COM, CHOICE.COM & CHANGE.COM
echo & GWBASIC (somewhere in the PATH is fine)
echo.
goto plum
:Display -----------------------------------------------------
echo MM=%mm%=month in hex SS=%ss%=total seconds in time
echo (hour,min,sec) YY=%yy%=1 digit for year
:End --------------------------------------------------- -vjf-
echo ? (%hr%*3600)+(%mn%*60)+(%sc%):system|gwbasic > ~~temp~~.bat
echo h$=hex$(%mm%):? h$:system|gwbasic >> ~~temp~~.bat
call change.com ~~temp~~.bat 13,10 32
for %%x in (dy hr mn sc) do set %%x=
call change.com ~~temp~~.bat 79,107,255 "~~^~~"
echo set ss=%%3>~~^~~.bat
echo set mm=%%8>>~~^~~.bat
call ~~temp~~
del ~~temp~~.bat
del ~~^~~.bat
set ymds=%YY%%MM%%DD%%SS%
echo;;|choice /c:;%ymds%; "~~~~~ ">~~~~.bat
call change ~~~~.bat 91,59,44 ""
echo set addxx=%%1%%2%%3%%4%%5%%6%%7%%8.%%9>~~~~~.bat
call ~~~~.bat
for %%y in (~~~~~ ~~~~) do del %%y.bat
:plum
---------------- snip ------------------
You'll have to null out the envars later yourself.
L8tr.
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 28 Mar 96 21:25:29
From: Tony Baechler Read: Yes Replied: No
To: Jeff Dubois Mark:
Subj: zipping gazillions of text files
──────────────────────────────────────────────────────────────────────────────
|Quoting Jeff to All on 18 Mar 96 23:55:18.|
JD> Is there a simply way, via batch, to zip up a gazillion *.TXT files
JD> into individual zip files and upon completion then delete all the
JD> *.TXT files in that directory?
I recently discovered a util by Horst in HORST_2.ZIP called LISTMOD.
COM which sounds like it might work. You will have to play around
with this a little, but I think something like this might work.
@ECHO OFF
DIR /B|LISTMOD /S. PKZIP $01 $01.$02 >OUT.BAT
CALL OUT.BAT
I am sure the following is not quite right, so experimentation is in
order here. HORST_2 was sent into BFDS.
Mail: 1:202/1333 or baechler@crl.com, ftp://ftp.crl.com/users/ba/baechler
... Is that your Tagline or did your mail reader throw up?
-!- Blue Wave/DOS v2.30
! Origin: Total Control BBS (ltd. hours) (1:202/1333)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 03 Apr 96 09:12:23
From: Vernon Frazee Read: Yes Replied: No
To: Bob Morton Mark:
Subj: JULIAN DATE 2 ENV
──────────────────────────────────────────────────────────────────────────────
BM> Does anyone have a batch segment that will read today's date and
BM> convert it to Julian format?
BM> Actually, I need to build up a filename that is guaranteed to be
BM> unique every time it is created. I need to use two characters out
BM> of the 8.3 format for another purpose, so I have 8.1 left for use.
BM> I was thinking of YJJJHHMM.SSXX where XX are the two characters I
BM> need to use, but as you can see, that's still one character too
BM> long. How about converting HHMMSS into relative seconds--a number
BM> from 1 to 86400? Hmmmmm..that would do it: changes 6 characters
BM> (HHMMSS) into 5 digits--YJJJSSSS.SXX
BM> Guess I'd better not do this arithmetic in batch unless one of the
BM> frequently mentioned utilities will do it.
How about doing it like this:
The 1st digit of the filename. Like you said, use 1 digit for the
year -- the last digit. For example, this is 1996 so it would be a
"6". (Of course this means that a decade from now a filename could
get overwritten <g>. I'll come back to this in a sec.).
The 2nd digit of the filename. Use 1 digit for the month -- "1"
thru "9" for Jan thru Sep, and then an "A", "B", and "C", for Oct,
Nov, and Dec respectively.
The 3rd digit of the filename. Use 1 digit for the day -- "1" thru
"9" for the 1st thru the 9th, and then an "A" for the 10th, "B" for
the 11th, "C" for the 12th etc. on up thru a "U" for the 31st day of
the month.
So far then, out of your "8.1" or "9 total digit" specification, we
have only used up three digits that cover the Year, Month, and Day.
That means we still have 6 digits for the hours, minutes, and
seconds. And, since the hours minutes and seconds are always no
more than two digits each, we can now simply use them without having
to convert a thing.
For example, right now it is | And for an example shows what
04/03/96 09:39:09 which means | happens when the month and day
the filename would be: | get up into the alphabetical
| chars., on 12/31/96 at 23:59:45
| the filename would be:
|
64309390.9 | 6CU23594.5
|||||||| | | |||||||| |
|||||||` `- Seconds | |||||||` `- Seconds
|||||``---- Minutes | |||||``---- Minutes
|||``------ Hours | |||``------ Hours
||`-------- Day | ||`-------- Day
|`--------- Month | |`--------- Month
`---------- Year | `---------- Year
(BTW, since "A", "B", "C" etc. come after "1", "2", "3" etc. when
sorted alphabetically, a sorted DIRectory listing will have the
filenames in sorted by date/time order).
Now back to the 10 year thing. In exactly 10 years from say
"12/31/96 at 23:59:45" it would be
"12/31/06 at 23:59:45" which, as you can see means that using
this approach will result with two identical filenames. This
probably won't be a problem however since most won't keep data
files for a decade. But, if so, one could simply create another
subdirectory to keep them in. Say for instance: C:\1990'S,
C:\2000'S, C:\2010'S etc. or C:\1996, C:\1997, . . . whatever).
If this approach sounds workable, here's a BATch file that uses
QBASIC to create the 8.1 portion of your filename and then sticks it
in an environment variable for you -- (so you can then tack on
whatever last two digits you want with your BATch file).
@echo off
:-----------------------------------------------------------------
:G9DFN.BAT - Generates a unique 9-Digit left justified 8.1 format
: FileName based on current system date & time.
: Requires: QBASIC (in PATH) and 16 bytes free environment space.
:-----------------------------------------------------------------
set G9DFN=
echo DIM wn(30):FOR x=1 TO 30:READ wn(x):NEXT x>~tmp~.bas
echo DATA 49,50,51,52,53,54,55,56,57,65,66,67,68,69,70>>~tmp~.bas
echo DATA 71,72,73,74,75,76,77,78,79,80,81,82,83,84,85>>~tmp~.bas
echo yy=VAL(MID$(DATE$,10,1)):mm=VAL(MID$(DATE$,1,2))>>~tmp~.bas
echo dd=VAL(MID$(DATE$,4,2)):hr$=MID$(TIME$,1,2)>>~tmp~.bas
echo mn$=MID$(TIME$,4,2):sc1$=MID$(TIME$,7,1)>>~tmp~.bas
echo sc2$=MID$(TIME$,8,1)>>~tmp~.bas
echo OPEN "~tmp~.bat" FOR OUTPUT AS #1>>~tmp~.bas
echo PRINT #1,"set G9DFN=";CHR$(wn(yy));CHR$(wn(mm));>>~tmp~.bas
echo PRINT #1,CHR$(wn(dd));hr$;mn$;sc1$;".";sc2$>>~tmp~.bas
echo CLOSE:SYSTEM>>~tmp~.bas
qbasic /run ~tmp~.bas
del ~tmp~.bas
for %%x in (call del) do %%x ~tmp~.bat
echo G9DFN=%G9DFN%
:End ------------------------------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate is now specially built for Internet! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 04 Apr 96 11:26:51
From: Vernon Frazee Read: Yes Replied: No
To: Jeff Cole Mark:
Subj: Need help with a BAT program
──────────────────────────────────────────────────────────────────────────────
JC> I regularly decode UUENCODED graphics files from an fidoecho. After
JC> saving the UUCODE posts, I drop to DOS decode the file, and then run
JC> my graphics program to see what it looks like. My question is, how
JC> can I call my graphics program and then return to the directory I
JC> called it from? My guess is something like this:
JC> cd < curdir
JC> cd c:\graphics\gds
JC> gds.exe
JC> cd %curdir%
JC> Would that work?
Unfortunately no, but, it really isn't much more complicated than
that. Here, try it like this:
@echo off
:GDS.BAT - Loads GDS and returns to current dir
:Save current drive:\dir -----------------------
echo @prompt cd $p$_$n:>%temp%\~tmp~.bat
%comspec% /c %temp%\~tmp~.bat>%temp%\return.bat
del %temp%\~tmp~.bat
:Load GDS --------------------------------------
for %%x in (c: cd\graphics\gds) do %%x
gds.exe %1 %2 %3 %4 %5 %67 %7 %8 %9
:Return to saved drive:\dir --------------------
for %%x in (call del) do %%x %temp%\return.bat
:End -------------------------------------------
Note: The five lines beginning with ":" can be removed if you like.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate is now specially built for Internet! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 422 Date: 04 Apr 96 22:37:05
From: James Hill Read: Yes Replied: No
To: MIKE DUTTERA Mark:
Subj: Get date?
──────────────────────────────────────────────────────────────────────────────
In a msg on <Mar 05 09:45>, MIKE DUTTERA of 1:270/616 writes:
SH>>What I'd like to do is have a plain vanilla batch file that
SH>>grabs the day of the month so that on the 3rd, for example, I
SH>>could defrag my HD, on the 4th run scandisk, etc. etc.
SH>>I figure it would have to be something that grabs the day of
SH>>the month as an env variable then the calling batch files
SH>>would check this to see if its the right day.
MD> Piece 'o cake. Just use MS-DOS's DATE and FIND functions in a
MD> batch using the general form:
MD> DATE|FIND "-03-"
MD> IF ERRORLEVEL 0 IF NOT ERRORLEVEL 1 GOTO BLAHBLAH
or you could have done;
echo.|date|find "-03-"|if not errorlevel 1 defrag c: /f /h /sn
echo.|date|find "-04-"|if not errorlevel 1 scandisk c: /autofix
enjoy.
-!- msgedsq 2.1
! Origin: Selective On-Line (tm) - Santa Fe, NM - (505) 473-9765 - (1:15/11)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 424 Date: 25 Mar 96 19:04:40
From: Michael Marquart Read: Yes Replied: No
To: Paul Laufer Mark:
Subj: Strip .EXT from command line
──────────────────────────────────────────────────────────────────────────────
~~ Paul Laufer said to All ~~
~~ Regarding Strip .EXT from command line ~~
~~ on 17 Mar 96 22:27:58 ~~
Hi Paul!
PL> TESTBAT.BAT C:\PATH\FILE.EXT
PL> ...I would like this batch file to know that this is an (EXT) file
PL> and "GOTO EXT". Then I could process the file as a .EXT file.
PL> If it's a .ZIP file it would "GOTO ZIP" in the batch process and
PL> I could process it as a .ZIP file.
Try this: tested on MSDOS V6.22 and uses only command.com.
:: Call_me_what_you_will.bat ===========================================
@echo off
set exten=%1
:nextchar
set prev=%exten%
for %%f in (/%exten%) do set exten=%%f
if ".%exten%"=="%prev%" goto extfound
if not "%exten%"=="%prev%" goto nextchar
echo There was no extension given on the command line for the filename!
goto end
:extfound
echo Extension is %prev%
for %%f in (/%prev%) do set ext=%%f
echo going to label %ext%
goto %ext%
:bat
echo :bat
goto end
:com
echo :com
goto end
:exe
echo :exe
goto end
:txt
echo :txt
goto end
:end
for %%f in (ext prev exten) do set %%f=
::======================================================================
The method was ripped off err... borrowed from one of the good denizens of
this echo!
Regards
Mic
... Clowns to the left of me, jokers to the right...
-!-
! Origin: Melbourne PC User Group +61-3-9699-6788 (3:632/309)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 07 Apr 96 06:43:35
From: Vernon Frazee Read: Yes Replied: No
To: Osgar Schaedtler Mark:
Subj: FIND, DELETE and FC
──────────────────────────────────────────────────────────────────────────────
OS> I've made a file, named FILE1.TXT, made with the command:
OS> DIR /B /A-D >FILE1.TXT
OS> Now I want to make a program that will do the following thing:
OS> The files in that directory have to be compared with the file
OS> FILE1.TXT. If there are some different files between the files in
OS> the directory and the files in FILE1.TXT, then I want to delete
OS> these files out of the directory. Has somebody an idea? I've
OS> tried something with the commands FIND and FC, but that didn't
OS> work. So, help me please!
There is an easier way. All it takes is one "for in do" command.
Let's say you have two directories. One named MASTER containing the
files you want to compare to, and another named FOOBAR that contains
a few files that are named the same as well as some extra junk files
that you want to get rid of. For example:
=================================+==================================
Directory of C:\MASTER | Directory of C:\FOOBAR
|
1 TXT 0 04-07-96 6:45a| 1 TXT 0 04-07-96 6:45a
2 TXT 0 04-07-96 6:45a| 2 TXT 0 04-07-96 6:45a
3 TXT 0 04-07-96 6:45a| 3 TXT 0 04-07-96 6:45a
| 4 TXT 0 04-07-96 6:45a
| 5 TXT 0 04-07-96 6:45a
=================================+==================================
(IOW, we want to get rid of "4.TXT" and "5.TXT" in C:\FOOBAR).
All it takes to do this is one DEL command.
First change to the directory that contains the files you want to
get rid of -- which in our example here is C:\FOOBAR. Now type the
following command at the DOS prompt:
--> for %x in (*.*) do if not exist c:\master\%x del %x
And that's it, you'll now have:
=================================+==================================
Directory of C:\MASTER | Directory of C:\FOOBAR
|
1 TXT 0 04-07-96 6:45a| 1 TXT 0 04-07-96 6:45a
2 TXT 0 04-07-96 6:45a| 2 TXT 0 04-07-96 6:45a
3 TXT 0 04-07-96 6:45a| 3 TXT 0 04-07-96 6:45a
=================================+==================================
Pretty "Kewl!" eh? <g>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 09 Apr 96 22:54:00
From: Benjamin L Mcgee Read: Yes Replied: No
To: All Mark:
Subj: CHEESY WINDOWS ENVIRON
──────────────────────────────────────────────────────────────────────────────
Here's a little somethin' I came up with so I can safely run
Binkley Term under Windows (so I can play Comet Busters while I
download QWK packets). It just prevents me from running Bink
twice which causes all sorts of problems, and it compensates for
the lack of a true environment variable under Windows. An old
trick I'm sure but I thought it might be helpful.
@echo off
cls
if exist c:\binkley\~windows.var goto error
:: set a HARD environment variable
rem > c:\binkley\~windows.var
:dumb
:: truncate log file
rem > c:\binkley\binkley.log
:: load vfos
c:\binkley\vfoss\vfos_ibm
c:
cd \binkley
bt.exe
:: unload vfos
c:\binkley\vfoss\vfos_del
del c:\binkley\~windows.var
goto quit
:error
echo.
echo Binkley Term is already running!
echo Running Bink twice under Windows is NOT good!
choice /cyn Do you wish to run Bink again anyway [Y/N]?
if errorlevel 2 goto quit
if errorlevel 1 goto dumb
:quit
Benjamin L McGee on 1:15/7
*Drop that pickle.
-!- FLAME v1.1
! Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 416 Date: 11 Apr 96 02:47:12
From: Vernon Frazee Read: Yes Replied: Yes
To: All Mark:
Subj: AVGFILES.BAT
──────────────────────────────────────────────────────────────────────────────
Hello all,
I'd sure appreciate if some of you running on MS-DOS 6.nn would run
the following and report back the resultant "average number of files
per directory" on your systems.
@echo off
:AVGFILES.BAT ------------------------------------------------------
goto Begin
:Syntax ------------------------------------------------------------
echo.
echo Name: AVGFILES.BAT v1.00
echo Author: Vernon Frazee 04/09/96
echo Purpose: Calculate the average number of files
echo per directory for the drive specified.
echo Syntax: AVGFILES d:
echo Where: "d:" is the drive to check
echo Requires: DOS' CHKDSK, FIND and QBASIC
echo (anywhere in PATH is fine).
echo Notes: Specified drive must contain at least one
echo directory and one file in the root directory.
echo Hidden files are NOT included.
echo Has only been tested on MS-DOS v6.nn
echo.
goto End
:Begin -------------------------------------------------------------
if (%1)==() goto Syntax
if not exist %1\nul goto DriveErr
if not exist %1\*.* goto FileErr
dir %1|find "DIR"|find " ">~tmp_01~.dat
copy ~tmp_01~.dat+,,>nul
if not exist ~tmp_01~.dat goto DirErr
:Gather data on specified drive ------------------------------------
echo.
echo Counting files and directories on drive "%1" ...
echo.
chkdsk %1|find /v "a"|find "in"|find /v "dd">~tmp_01~.dat
:Display CHKDEK data -----------------------------------------------
echo CHKDSK data for drive "%1"
echo.
type ~tmp_01~.dat
echo.
:Create QBASIC program to do the calculations ----------------------
echo OPEN "~tmp_01~.dat" FOR INPUT AS #1>~tmptmp~.bas
echo OPEN "~tmp_02~.dat" FOR OUTPUT AS #2>>~tmptmp~.bas
echo DO WHILE NOT EOF(1)>>~tmptmp~.bas
echo LINE INPUT #1, Rec$>>~tmptmp~.bas
echo Rec$ = MID$(Rec$, 24, 18)>>~tmptmp~.bas
echo FOR Count = 1 TO 18>>~tmptmp~.bas
echo IF MID$(Rec$, Count, 1) = "," THEN>>~tmptmp~.bas
echo Stn$ = "">>~tmptmp~.bas
echo END IF>>~tmptmp~.bas
echo IF NOT MID$(Rec$, Count, 1) = "," THEN>>~tmptmp~.bas
echo Stn$ = MID$(Rec$, Count, 1)>>~tmptmp~.bas
echo END IF>>~tmptmp~.bas
echo IF UCASE$(Stn$) = LCASE$(Stn$) THEN>>~tmptmp~.bas
echo x$ = x$ + Stn$>>~tmptmp~.bas
echo END IF>>~tmptmp~.bas
echo NEXT Count>>~tmptmp~.bas
echo PRINT #2, x$>>~tmptmp~.bas
echo x$ = "">>~tmptmp~.bas
echo LOOP>>~tmptmp~.bas
echo CLOSE>>~tmptmp~.bas
echo OPEN "~tmp_02~.dat" FOR INPUT AS #1>>~tmptmp~.bas
echo LINE INPUT #1, d$: LINE INPUT #1, f$>>~tmptmp~.bas
echo a = CSNG(VAL(f$) / VAL(d$))>>~tmptmp~.bas
echo a$ = LTRIM$(RTRIM$(STR$(a)))>>~tmptmp~.bas
echo PRINT "Average number of files";>>~tmptmp~.bas
echo PRINT " per directory: "; a$>>~tmptmp~.bas
echo CLOSE : SYSTEM>>~tmptmp~.bas
:Run QBASIC program ------------------------------------------------
qbasic /run ~tmptmp~.bas
echo.
goto Cleanup
:DriveErr ----------------------------------------------------------
echo.
echo Error: Drive "%1" is not a valid drive
goto Syntax
:FileErr -----------------------------------------------------------
echo.
echo Error: Drive "%1" must contain at least
echo one file in the root directory
goto Syntax
:DirErr ------------------------------------------------------------
echo.
echo Error: Drive "%1" must contain at least
echo one subdirectory
goto Syntax
:Cleanup -----------------------------------------------------------
for %%x in (1 2) do del ~tmp_0%%x~.dat
del ~tmptmp~.bas
:End --------------------------------------------------------- -vjf-
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 418 Date: 09 Apr 96 08:23:00
From: Horst Schaeffer Read: Yes Replied: No
To: Scott Sellars Mark:
Subj: Batch File Help...
──────────────────────────────────────────────────────────────────────────────
-=> quoting Scott Sellars to Clay Cherneff (5 Apr 96) <=-
SS> I want to generate errorlevels so i can test out my batch files.
some errorlevel test tools:
-+-+-----
n EL!.COM
e100 BE 81 0 AC "< t"FB "N<0r"1B "+"C0 "*"FF BA A 0 8A 1C "F"80 EB "0"
e11A ":"DA "s"6 F7 E2 1 D8 "s"ED B4 "L"CD "!"BA "3"1 B4 9 CD "!*"C0 EB
e132 F1 "EL! n"D A "sets errorlevel to n=0..255"D A "$"
rCX
58
w
q
-+-+-----
Cut out and save (any filename), then run: DEBUG < filename
-+-+-.... and to display the errorlevel:
@echo off
:: return errorlevel EL & echo
set !=
set EL=
for %%h in (0 1 2) do if errorlevel %%h00 set EL=%%h
if not errorlevel 200 set !=6 7 8 9
for %%t in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%t0 set EL=%EL%%%t
if not errorlevel 250 set !=6 7 8 9
for %%u in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%u set EL=%EL%%%u
echo Errorlevel %EL%
set !=
-+-+-
Horst.
... Q4FM 2.10 ... horst@confusion.rmc.de
-!- FM 2.02 / ScanToss
! Origin: Don't follow leaders! (2:2480/13.75)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 14 Apr 96 20:48:00
From: Benjamin L Mcgee Read: Yes Replied: No
To: Jay Fuller Mark:
Subj: QUESTION CONCERNING "FIND
──────────────────────────────────────────────────────────────────────────────
On 04-09-96 JAY FULLER wrote to ALL...
JF> Greetings everyone,
Hello!
JF> I'm attempting to write a batch file that will do the
JF> following.....
JF> if find log.txt "SUCCESS" goto success
JF> if find log.txt "ILLEGAL" goto illegal
Do you program in 'C' or 'C++'? DOS's IF just ain't that good.
added /i to ignore case
added > nul to hide output of find
find returns errorlevel 2 if an error occured while trying
to read from the file, errorlevel 1 if no error occured but the
search string wasn't found, and errorlevel 0 if no error occured
and the search string was found
find /i "SUCCESS" LOG.TXT > nul
if errorlevel 2 goto error
if not errorlevel 1 goto success
find /i "ILLEGAL" LOG.TXT > nul
if errorlevel 2 goto error
if not errorlevel 1 goto illegal
Benjamin L McGee on 1:15/7
*Don't read everything you believe.
-!- FLAME v1.1
! Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 439 Date: 16 Apr 96 21:16:19
From: Vernon Frazee Read: Yes Replied: No
To: Kenny Eschrich Mark:
Subj: old tandy-autoexec
──────────────────────────────────────────────────────────────────────────────
KE> I've got a real old Tandy 1000. In order to use the disk drive, i
KE> have to type F3 before it says Starting IB DOS. Is there any way
KE> i can do this automatically in like my autoexec or config or
KE> whatever?
Press the [F3] function key? I don't believe I've ever heard of
that one. Maybe it will only boot from ROM (Read-Only Memory)?
Anyway, in answer to your question, probably not. When you see:
Starting MS-DOS ...
nothing in CONFIG.SYS has even been processed yet. The processing
steps involved in a 'normal' MS-DOS startup is as follows:
:Begin
1) ROM program loads the bootstrap program from disk
2) Bootstrap loads hidden system files and passes control to them
3) ROM programs and the DOS BIOS combine to produce the I/O code
4) DOS system generation begins
5) Does CONFIG.SYS exist?
No - use default DOS values and goto "6)"
Yes - modify DOS default parameters and install user-specified
device drivers
6) Is the command processor COMMAND.COM?
No - Invoke startup portion of the command processsor and
goto "End"
Yes - Invoke startup portion of COMMAND.COM
7) Is AUTOEXEC.BAT present?
No - Issue DOS Date and Time commands and goto "End"
Yes - Perform the commands in AUTOEXEC.BAT
8) Terminate the startup portion of COMMAND.COM
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 13 Apr 96 17:57:22
From: Geoff Cutter Read: Yes Replied: No
To: Bob Morton Mark:
Subj: Unique file name - was JULIAN DATE 2 ENV
──────────────────────────────────────────────────────────────────────────────
On 07 Apr 96 10:12:00, Bob Morton wrote to Geoff Cutter
BM> Unfortunately, I need granularity finer than "minute." It is possible
BM> two files will be created within the same minute, which would result
BM> in identical filenames.
Perhaps reserve a character for incrementing:
set jj=0
:again
REM increment here
if exist xxxxxxxx.xx%jj% goto again
REM unique name found
Several programs can increment - any of these:
BATCHMAN LZH 46761 10/03/94 23:13
FDATE91C ZIP 76262 23/10/95 1:56
GET27 ZIP 117869 31/05/95 19:41
INCVAR LZH 7598 27/11/93 19:08
PSIS-500 LZH 22972 15/05/95 5:00
or you could modify Vernon's batch program:
Date: 07 Apr 94 03:04:11
From: Vernon Frazee
Subj: Auto Backups
The following COUNT.BAT will keep track of how many times it has
been run. Change ALL of the "c:\bat" 's to the name of your
BATch file directory on your system. (Must be in your PATH too).
@echo off
:COUNT.BAT - Increments the COUNT each time run - (Self modifying!) ----
if not (%1)==(/?) goto BEGIN
echo Syntax: COUNT [/0] (Optional "/0" means initialize)
goto END
:BEGIN -----------------------------------------------------------------
set count=1
if not (%1)==(/0) goto COUNT
:Initialize ------------------------------------------------------------
find /v ":%count%"<c:\bat\count.bat>c:\bat\count.bat
goto END
:COUNT -----------------------------------------------------------------
echo :%count%>>c:\bat\count.bat
find /c ":%count%" c:\bat\count.bat>countemp.bat
echo set count=%%2>--------.bat
for %%x in (call del) do %%x countemp.bat
del --------.bat
set count=%count%
:END (Note: COUNT.BAT data storage below) ------------------------ -vjf-
The following example, W.BAT, uses the above COUNT.BAT to keep track
of how many times it has been run. Change whatever you like to suit
your specific requirements:
@echo off
:W.BAT - Loads WORD each time run and also does a "modified
: files only" backup to drive B: every 30th time run.
:Notes - Requires COUNT.BAT and DOS's XCOPY both be available
: somewhere in current PATH.
:Begin --------------------------------------------------------
echo Loading: WORD ...
c:
cd\word
word
call count
echo.
echo Word has been run %count% times since last backup to B:
if not (%count%)==(30) goto DONE
:Backup -------------------------------------------------------
echo.
echo Please insert your "Word Backup Diskette" in drive
echo B: and press any key to begin copying file(s). . .
echo.
pause>nul
xcopy c:\word b:\ /m /s /e
call count /0
:DONE ---------------------------------------------------------
cd\
echo.
:End ---------------------------------------------------- -vjf-
regds Geoff
-!- Blue Wave/DOS v2.30
! Origin: TARDIS BBS (03) 9819 7093 (3:633/260)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 23 Apr 96 11:26:07
From: Vernon Frazee Read: Yes Replied: No
To: Roy Reed Mark:
Subj: DECIMAL TO HEX
──────────────────────────────────────────────────────────────────────────────
RR> Here is a decimal to hex converter, but it's 400 some bytes.
RR> -+-+--------------------------------------------------------
RR> n BREAKOUT.LZH
RR> e100 FC "+"ED BE 82 1 B9 80 FD B4 "?U[VZ"CD "!r`PY"F7 D8 99 ...
How about a simple BATch-file/QBASIC solution:
@echo off
:HEX.BAT ----------------------------------------------
if (%1)==() goto Syntax
if (%1)==(/?) goto Syntax
:Begin ------------------------------------------------
echo A$=HEX$(%1):? A$:system>~tmptmp~.bas
qbasic /run ~tmptmp~.bas
del ~tmptmp~.bas
goto End
:Syntax -----------------------------------------------
echo Syntax: HEX nnn
echo Where: nnn is a Decimal number that you want
echo converted to a Hexadecimal number
echo Note: nnn can be up to nine 9's worth.
:End -------------------------------------------- -vjf-
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 23 Apr 96 11:26:06
From: Vernon Frazee Read: Yes Replied: No
To: Malcolm Campbell Mark:
Subj: JULIAN DATE 2 ENV
──────────────────────────────────────────────────────────────────────────────
AG> In a message originally to Malcolm Campbell, Vernon Frazee said:
AG> :ZIPLOG.BAT - Change to the directory containing the .LOG file(s)
AG> to ZIP and type "ZIPLOG" (no quotes).
MC> I seem to have missed this ;-( Can you please repost?
Here you go:
:ZIPLOG.BAT - Change to the directory containing the .LOG
: file(s) to ZIP and type "ZIPLOG" (no quotes).
:Note: Do NOT put a "@echo off" at the beginning of this file!
:Begin -------------------------------------------------------
@if (%1)==(/?) goto Syntax
@if (%1)==(!!) goto GetMDY
@if (%1)==(!) prompt set date=!! $d
@if (%1)==(!) goto End
@echo off
for %%x in (date mm dd yy) do set %%x=
command /c %0 !>~tmp_01~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
%0 %date%
:GetMDY ------------------------------------------------------
shift|shift
echo;;|choice /c:;%1%; "~tmp_02~ ">~tmp_01~.bat
echo set mm=%%2%%3>>~tmp_02~.bat
echo set dd=%%5%%6>>~tmp_02~.bat
for %%x in (1 2) do echo shift>>~tmp_02~.bat
echo set yy=%%8%%9>>~tmp_02~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
del ~tmp_02~.bat
:Zip'em ------------------------------------------------------
pkzip -ex %yy%%mm%%dd% *.LOG
dir %yy%%mm%%dd%.zip
:Cleanup -----------------------------------------------------
for %%x in (date mm dd yy) do set %%x=
:End ---------------------------------------------------------
Requires CHOICE.COM and maybe 30 bytes free environment space.
MC> Thanks!
Sure; no problem.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 444 Date: 25 Apr 96 17:25:00
From: Ron Warder Read: Yes Replied: No
To: Jerry Dugal Mark:
Subj: count lines in txt file
──────────────────────────────────────────────────────────────────────────────
>I need to count the # of lines in a txt file, any one have an idea on the
>best way to go about doing this?
Here ya go, courtesy of Prof. Timo Salmi, Finlands resident DOS guru:
:: LC.BAT -----------------------------------------------------------
@echo off
echo +---------------------------------------------------+
echo . Count the number of lines in the given TEXT file .
echo . By Prof. Timo Salmi, ts@chyde.uwasa.fi, 6-Dec-91 .
echo +---------------------------------------------------+
rem If no parameters then give the instructions
if "%1"=="" goto _help
rem Check that the file exists
if not exist %1 goto _nofind
rem Count the lines
:: Note: As posted in TSBATxx.ZIP, the line below has an error in the
:: find string. The single "%" should have been "%%", since the single
:: percent sign is absorbed by DOS's batch handler.
:: find /v /c "2O4$fD%h38+" %1
find /v /c "2O4$fD%%h38+" %1
goto _out
:_help
echo.
echo Usage: LC FileName
goto _out
:_nofind
echo.
echo File %1 not found
goto _out
:_out
echo on
:: End of LC.BAT ----------------------------------------------------
This gives you a count of the number of lines in the specified file by
telling you how many lines -don't- contain the string "2O4$fD%%h38+". Any
string will work, so long as it is unique enough to -not- appear in the file
specified. The string given is as unique as any that I have ever come up with.
If the file being operated on contains that particular string, the result from
LC.BAT will be off by the number of lines that contain the search string.
Hope this helps solve the problem ....
-!- SLMAIL v4.0a (#0304)
! Origin: Free Spirit =*= SL/RIP =*= 301-283-0917 =*= V32b/HST (1:109/132)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 437 Date: 24 Apr 96 20:57:24
From: Larry Nelson Read: Yes Replied: No
To: Bill Martin Mark:
Subj: For/in/Do ?
──────────────────────────────────────────────────────────────────────────────
BILL:
Subject: FOR/DO... Clean and Concise explinations?
BM> Can someone offer c clear idea of the usage for "FOR" / "DO". I for BM>
one reason or another am having a problem getting a grasp on this. BM>
Especially when it is used to run multiple functions on multiple files...
Maybe a BM> "easy" example, as well as an intermediate on and an advanced one?
The problem you mention is going to need a recursion routine
but let's start off with a basic For command.
FOR/IN/DO LOOP:
The For/in/Do loop is so named for the three words needed to
make it work. DOS help has a bit to say on the subject and
while that is a good place to satrt there is a good deal
more to know about FOR. For is made up of three main parts.
The call "for", the set "in (.....)", and the command.
for %%q in (this is a for loop) do echo %%q
^ ^ ^^^^ ^^ ^ ^^^ ^^^^ ^ ^
| | |
The call The set (5 strings) The command
For cycles through the 5 strings in this set one at a time with
the help of %%q. %%q is a local variable that takes on the value
of each part of the set in turn.
In people speak one could translate the first cycle of this
For/in/DO loop as "For this do echo this". The next cycle, "For
is do echo is".....and so on. the screen result would be......
this
is
a
for
loop
Echoing a list of words probably isn't the most exciting
thing you have seen a Batch command do so hows about putting
5 file names in the set....
For %%q in (this.com is.bat a.txt for.lst loop.pft) do del %%q
...and now we have a tool that deletes 5 files.
For nibbels at the edges of real loopdom in that it is controled
by the number of strings in the set. The efforts needed to get
any great amount of work out of it, however, boarder on the
gymnastic.
And now to your more advanced question. For can do something
to a bunch of things or it can do a bunch of somethings to
one thing, but it can't do a bunch of somethings to a bunch
of things. Not wothout help that is, and that is where
recursion comes in.
RECURSIONS:
Recursion happens when a Batch file calls itself. Why? You say.
Well one reason a .bat might need to recycle itself is to run
multiple functions on multiple files. For/in/do loops won't nest,
try it and DOS will slap your hands.
This....
for %%q in (dos mail wrk) do for %%a in (*.bak *.tmp) del %%a
will get you this....
FOR cannot be nested
Oh poo! Well not to fret, Recursion to the rescue......
@echo off
cls
if not %1! == ! goto %1
for %%q in (dos mail wrk) do call %0 step2 %%q
goto L8r
:step2
for %%q in (c:\%2\*.bak c:\%2\*.tmp) do del %%q
:L8r
Not so pretty as the line we tried above, but it has the advantage
of not offending Command.com. The first "For" recalls the .bat "%0"
with the parameters "step2" and "%%q" which is "dos", "mail"
and "wrk" in turn. The second "For" processes, in turn, each
directory by deleting each ".bak" and ".tmp" file from the
directory named in that current cycle of For#1. "c:\%2\%%q"
in the first cycle of For#2 reads as c:\dos\*.bak. In the
second cycle it reads "c:\dos\*.tmp"
Neat Huh!
:L8r
Larry
..... In a pinch a stone ax still works.....
-!- Maximus 2.02
! Origin: MSDOS MAXIMUS BBS (1:343/101)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 408 Date: 26 Apr 96 17:38:12
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: 1aday.bat 2/2
──────────────────────────────────────────────────────────────────────────────
[ ...Continued From Previous Message ]
@echo off
:1ADAY.BAT runs a specified program once-a-day only ---------------
if not (%0)==(1ADAY.BAT) 1ADAY.BAT %1 %2 %3 %4 %5 %6 %7 %8 %9
if (%1)==(/?) goto Syntax
if not (%1)==() goto Begin
:Syntax -----------------------------------------------------------
echo Name: 1ADAY.BAT
echo Purpose: Run a specified command only once a day
echo Syntax: 1ADAY program_name/command [parms...]
echo 1ADAY /C clears all entries
echo 1ADAY /? displays this help
echo Example: 1ADAY DEFRAG C: /F /SN
echo Requires: DOS v6.nn+'s FIND.EXE (in current PATH) and
echo 29 bytes free environment space.
echo Important: 1ADAY.BAT is self modifying! It keeps track of
echo when and what was run at the end of itself.
echo Therefore all occurences of "1aday.bat" below
echo must be changed to include the complete path to
echo 1ADAY.BAT. From "1aday.bat" to "c:\bat\1aday.bat"
echo for example.
goto End
:Begin ------------------------------------------------------------
set ~prefix~=:
set ~prefix~=%~prefix~%:!
for %%x in (c C) do if (%1)==(/%%x) goto ClearData
:GetDate ----------------------------------------------------------
echo set ~date~=%%3>~tmptmp1.bat
dir/-p ~tmptmp1.bat|find "~TMPTMP1 BAT">~tmptmp2.bat
for %%x in (call del) do %%x ~tmptmp2.bat
del ~tmptmp1.bat
:Has current command already been run today? ----------------------
find/i "%~prefix~%%~date~%%1%2%3%4%5%6%7%8%9" 1aday.bat>nul
if errorlevel 1 goto Nope
:Yep ----------------------------
echo The command:
echo %1 %2 %3 %4 %5 %6 %7 %8 %9
echo has already been run today.
goto Cleanup
:Nope ---------------------------
echo %~prefix~%%~date~%%1%2%3%4%5%6%7%8%9>>1aday.bat
call %1 %2 %3 %4 %5 %6 %7 %8 %9
goto Cleanup
:ClearData --------------------------------------------------------
type 1aday.bat|find /v "%~prefix~%">1aday.bat
:Cleanup ----------------------------------------------------------
rem for %%x in (prefix date) do set ~%%x~=
:End - Data storage begins below. - Type "1ADAY /?" for info. -----
::!04-23-96dirg:\*.*
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 419 Date: 26 Apr 96 12:57:21
From: Michael Barnes Read: Yes Replied: No
To: Jason Laviska Mark:
Subj: Command line arguments
──────────────────────────────────────────────────────────────────────────────
Jason Laviska wrote in a message to All:
JL> Is there a way to transmit the entire list of command
JL> parameters to a program which will allow me to use more than nine
JL> arguments using a batch file in dos 6.x? Right now all I have
JL> is...
JL> @Echo off
JL> C:\LASRCOMP\LASRCOMP.EXE %1 %2 %3 %4 %5 %6 %7 %8 %9
JL> If Errorlevel==0 Echo Files are identical
JL> If Errorlevel==255 Echo Files are different
'Lo Jason,
Yes, use the shift command. (as in the example below)
but first.. you must list your errorlevel checks in reverse order- such as:
IF ERRORLEVEL 255 GOTO ERROR255
IF ERRORLEVEL 254 GOTO ERROR254
~~~
IF ERRORLEVEL 1 GOTO ERROR001
IF ERRORLEVEL 0 GOTO ERROR000
-!- Now on to the example ---
10PLUS.BAT
:START
IF '%2'=='' THEN SET LASTPARAM=TRUE
ECHO %1>>OUTPUT.TXT
IF '%LASTPARAM%'=='TRUE' THEN GOTO END
SHIFT
GOTO START
:END
TYPE OUPUT.TXT |MORE
-!- So, type:
10PLUS ONE 2 THREE 4 FIVE 6 SEVEN 8 NINE 10 ELEVEN 12 THIRTEEN 14 [ENTER]
and the file OUPUT.TXT will contain all 14 parameters. (the magic is in the
shift)
Sincerely,
Michael
-!- GEcho 1.20/Pro
! Origin: On a clear disk, you can seek for ever (1:271/210)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 439 Date: 26 Apr 96 17:38:10
From: Vernon Frazee Read: Yes Replied: No
To: Ronald Mendoza Mark:
Subj: Random message display
──────────────────────────────────────────────────────────────────────────────
RM> Now what exactly do you mean by "CHOICE.COM" is required in the PATH
RM> somewhere...How do you do this?? ANything special? Or do I just add
RM> "c:\dos\choice.com" to my path in my autoexec.bat???? Please clarify
RM> this for me! Thanks a lot!
At the DOS prompt, you can type:
PATH
to view the directories in your current PATH.
If you keep CHOICE.COM in your C:\DOS directory, (most do), just
make sure the directory:
C:\DOS
is one of the directories in your current PATH.
For example, here is the beginning of my current PATH (displayed by
typing "PATH"):
PATH=g:\key;c:\bat;c:\util;c:\dos;c:\pk;c:\scan
~~~~~~
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 440 Date: 25 Apr 96 10:45:48
From: Vernon Frazee Read: Yes Replied: No
To: Jesse Jordan Mark:
Subj: Random numerical stuff
──────────────────────────────────────────────────────────────────────────────
Hello Jesse,
If I've already answered the following, please ignore this dupe.
BBN, "Buggy BossNode" ;(
JJ> Great so far! I have no idea how you got the date in this message,
JJ> but could you get the little split-seconds? I could use that
JJ> variable for the random number. And since it needs to be under 100,
JJ> 60 works great... That way, the role-playing character can start
JJ> low, and work stats up. See, in using seconds, I usually get stats
JJ> like this:
JJ> 15
JJ> 22 <--doesn't take this much time, but the example stands of it
JJ> 35 <--passing from lesser to greater.
JJ> 46
JJ> 56
JJ> It creates them in numerical order as the calls to the
JJ> variable-catching bat are made.
JJ> To speed things up, how about a bat the only catches the
JJ> splitsecond? <I couldn't do it if my life depended on it.>
@echo off
:RND.BAT - Copies the two digit hundredths-of-a-second
: from the current system time into an
: environment variable named RND. Requires
: DOS's CHOICE.COM (somewhere in the PATH) and
: 17 bytes free environment space.
:Begin -------------------------------------------------
ver|time>~rndtmp~.bat
echo set rnd=%%3>current.bat
call ~rndtmp~.bat
del current.bat
echo;;|choice /c:;%rnd%; "current ">~rndtmp~.bat
for %%x in (1 2 3 4 5 6 7 8) do echo shift>>current.bat
echo if not (%%1)==(.) shift>>current.bat
echo if (%%1)==(.) shift>>current.bat
--> echo set rnd=%%1%%2>>current.bat
for %%x in (call del) do %%x ~rndtmp~.bat
del current.bat
echo RND=%rnd%
:End --------------------------------------------- -vjf-
Note: You can simply change the "%%1%%2" in the line marked with
"-->" to "%%2%%1" if you'd rather have the second digit of the
100ths of a second first. For example, as it is, if the
current time was "10:49:15.24a" the RND evar would be "24".
If you reverse the %%1%%2 to %%2%%1, it would be "42".
JJ> Thanks for your help!
Sure, no problem.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate IS the final terminal! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 418 Date: 26 Apr 96 08:36:01
From: Greg Smith Read: Yes Replied: No
To: Jerry Dugal Mark:
Subj: count lines in txt file
──────────────────────────────────────────────────────────────────────────────
For reasons that are still not clear, Jerry Dugal said...
JD> I need to count the # of lines in a txt file, any one have an idea on
JD> the best way to go about doing this?
Here we have one of those cases where we use a DOS command for something
completely different than what it was intended for...
@echo off
:: LCOUNT.BAT - puts line count of specified file into LINES env variable
:: ---------------------------
:: Usage: LCOUNT filename.ext
:: ---------------------------
if (%1) == () EXIT
echo IF (%%1%) == () GOTO RERUN > --------.BAT
echo SET LINES = %%2% >> --------.BAT
echo GOTO EXIT >> --------.BAT
echo :RERUN >> --------.BAT
find /V /C "-[gobbley&gook]-" %1 >> --------.BAT
:: you can use any "string" that you KNOW is NOT in the TEXT file to search.
echo :EXIT >> --------.BAT
call --------.BAT
del --------.BAT
-!- JMail-G 2.80a
! Origin: ACCENT! - Chandler, AZ - (602) 814-7894 (1:114/402)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 429 Date: 26 Apr 96 12:03:11
From: Vernon Frazee Read: Yes Replied: No
To: Jerry Dugal Mark:
Subj: count lines in txt file
──────────────────────────────────────────────────────────────────────────────
JD> I need to count the # of lines in a txt file, any one have an idea
JD> on the best way to go about doing this?
If you mean count all the lines in a text file that:
1) actually contain text (in other words, don't count the
blank lines)
and
2) all the lines of text have at least one space somewhere in
the line
then the following DOS command will work:
TYPE name_of_file|FIND /C " "
If you want to count _ALL_ of the lines in a text file AND you know
that NONE of the lines would contain some strange sequence of
characters like say:
~!1@2#3$4~
the following DOS command will work:
TYPE name_of_file|FIND /C /V "~!1@2#3$4~"
And if you wanted to do something like count only the lines that had
the string "the" in them, either upper- or lower-case, the command
would be:
TYPE name_of_file|FIND /C /I "the"
How many fonts are being loaded in Windows 3.1n's WIN.INI?
TYPE C:\WINDOWS\WIN.INI|FIND /C ".FO"
'Kewl' eh? <g>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Get real, get better, get faster, get Terminate! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 28 Apr 96 11:58:00
From: Benjamin L Mcgee Read: Yes Replied: No
To: Vernon Frazee Mark:
Subj: ERRORLEVEL
──────────────────────────────────────────────────────────────────────────────
BLM> if errorlevel 255 echo 255
BLM> if etc. etc. etc. ...
BLM> if not errorlevel 1 echo 0
VF> How about something just a wee bit shorter (and faster)
VF> than the above 257-line (minimum) monster:
[inspiring code deleted....]
Your code inspired me to pen the following, which seemes to work
fine for me. Do you see any potential (or current) problems with
it. Thanx blm
@echo off
:: EL.BAT blm 1996
:: Set "ERROR" environment variable to last ERRORLEVEL
:: and echo ERRORLEVEL
set error=
set errh=0
set errm=0
set errl=0
for %%h in (1 2) do if errorlevel %%h00 set errh=%%h
for %%m in (1 2 3 4 5 6 7 8 9) do if errorlevel %errh%%%m0 set errm=%%m
for %%l in (1 2 3 4 5 6 7 8 9) do if errorlevel %errh%%errm%%%l set errl=%%l
for %%e in (%errh% %errm% %errl%) do if not "%%e"=="0" set error=%error%%%e
if "%error%"=="" set error=0
set errh=
set errm=
set errl=
echo Errorlevel %error%
Benjamin L McGee on 1:15/7
*FACT: There are more horse's asses than there are horses
-!- FLAME v1.1
! Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 29 Apr 96 18:42:00
From: Jason Laviska Read: Yes Replied: No
To: All Mark:
Subj: Command line arguments
──────────────────────────────────────────────────────────────────────────────
After all useful messages concerning the SHIFT function, I would like to
say thanks to those who have responded with tips and hints. I have pretty much
combined all the messages regarding this topic and ended up using this batch
file below. This message is mainly for those people who helped me, but
couldn't come up with the full solution. If you see any problems with it, let
me know.
@Echo Off
If Exist LCDATA.TMP Del LCDATA.TMP >Nul
If "%1"=="" Goto ERROR
:START
If "%1"=="" Goto RUNLC
Echo %1 >>LCDATA.TMP
SHIFT
GOTO START
:ERROR
Echo No Command Line Parameters!
C:\LASRCOMP\LASRCOMP.EXE /?
Goto END
:RUNLC
C:\LASRCOMP\LASRCOMP.EXE @LCDATA.TMP
Del LCDATA.TMP >Nul
:END
First it will check to see if the temporary exists, and if so, it will
delete it. Next, it will create a file called LCDATA.TMP and store all the
command line variables by looping the command arguments using the SHIFT
command. If there are no arguments were given to the batch file, it will
display the help file for LASRCOMP.EXE using the /? switch. Afterwards, it
will then run the program using the temporary file as its command parameter.
(LaserCompare WILL read the file contents and use it as its command line if you
put a "@" sign in front of it.) In the end, the batch file will discard the
temporary file.
- Jason Laviska
! Origin: _C_E_N_T_R_A_L__S_T_A_T_I_O_N_ * OS/2 * Melbourne,FL * (1:374/31)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 434 Date: 29 Apr 96 05:31:26
From: Vernon Frazee Read: Yes Replied: No
To: Gary Smith Mark:
Subj: ERRORLEVEL
──────────────────────────────────────────────────────────────────────────────
VF> How about something just a wee bit shorter (and faster) than the
VF> above 257-line (minimum) monster:
GS> Your routine is prretty cool, but this one is shorter and uses no
GS> more than seven bytes of environment space.
GS> @echo off
GS> ::
GS> :: Set environment variable EL to the current error level,
GS> :: expressed as a 1-3 digit number (leading zeros suppressed).
GS> ::
GS> for %%h in (0 1 2) do if errorlevel %%h00 set EL=%%h
GS> if %EL% == 0 set EL=
GS> if errorlevel 200 for %%t in (0 1 2 3 4 5) do if errorlevel
GS> 2%%t0 set EL=2%%t
GS> if not errorlevel 200 for %%t in (0 1 2 3 4 5 6 7 8 9) do if
GS> errorlevel %EL%%%t0 set EL=%EL%%%t
GS> if %EL% == 0 set EL=
GS> if errorlevel 250 for %%u in (0 1 2 3 4 5) do if errorlevel
GS> 25%%u set EL=%EL%%%u
GS> if not errorlevel 250 for %%u in (0 1 2 3 4 5 6 7 8 9) do if
GS> errorlevel %EL%%%u set EL=%EL%%%u
GS> echo Error level = %EL%
GS>
GS> Note: indented lines are continuations for the preceding lines, so
GS> there are actually only seven "working" lines in the file. If you
GS> want a result that's always three digits, instead of dropping
GS> leading zeros, remove the two lines which begin "if %EL% == 0".
Pretty cool! Beat my filesize by a single byte. Yours was 444
compared to mine at 445. Went to work on yours though and durn
near whittled 100 bytes, down to 348:
@echo off
set A=0 1 2 3 4 5
set B=%A% 6 7 8 9
set C=errorlevel
set D=) do if %C%
set F=for %%x in (
set G= set E
%F%0 1 2%D% %%x00%G%=%%x
if %C% 200 %F%%A%%D% 2%%x0%G%=2%%x
if not %C% 200 %F%%B%%D% %E%%%x0%G%=%E%%%x
if %C% 250 %F%%A%%D% 25%%x%G%=%E%%%x
if not %C% 250 %F%%B%%D% %E%%%x%G%=%E%%%x
echo %E%
%F%A B C D E F G) do set %%x=
Applied the same technique to mine and it's now at 329 bytes:
@echo off
set F=for %%x in (
set E=errorlevel|%F%A B) do set %%x=0 1 2 3 4 5
if not %E% 250 set A=%A% 6 7 8 9
if not %E% 200 set B=%A%
%F%1 2) do if %E% %%x00 set C=%%x
%F%%B%) do if %E% %C%%%x0 set D=%%x
if (%C%%D%)==(0) set D=
set C=%C%%D%
%F%%A%) do if %E% %C%%%x set D=%C%%%x
echo %D%
%F%A B C D E F) do set %%x=
(Yours displays errorlevels with leading zeros, mine does not).
Of course as you can tell, with these particular variations I wasn't
worried about environment space nor the number of lines. All I was
really concerned with is simply the fewest number of bytes required
to get the job done, (and, using nothing more than COMMAND.COM).
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate is available from a dealer near you! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 07 May 96 21:12:10
From: Andy Guess Read: Yes Replied: No
To: Larry Kwiatkowski Mark:
Subj: FOR/DO... Clean and Conc
──────────────────────────────────────────────────────────────────────────────
LK->Hokay - I understand the for-in-do function. Could anyone hazard a guess wh
LK->it will not work, for example, in autoexec with multiple "set" commands? Th
LK->has always puzzled me.
For multiple SET's on one line, use:
SET variable1=value1|SET variable2=value2|SET variable3=value3
You can do that as long as the line is less than 128 characters.
Hope I helped!
Cya,
-AG
* SLMR 2.1a * Is this yours? Your dog left it on my lawn ...
-!-
! Origin: * My Place BBS * Bowie, Md USA * V.34 * (301)805-1602 * (1:109/570)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 450 Date: 06 May 96 14:58:47
From: Vernon Frazee Read: Yes Replied: No
To: Joe Kron Mark:
Subj: Text Input HELP!
──────────────────────────────────────────────────────────────────────────────
JK> See PC Mag. 5-25-'93 pg. 299. This is one of many third party string
JK> input utilities. ANSWER is another in The Best of IBM PC Shareware
JK> that puts the string in an EVAR. There is also PC Mag's STRINGS
JK> which does this and more. But I must say the best answer is still
JK> 4DOS.
Why go searching for a third and/or spending money when DOS provides
the capability?
@echo off
:INPUT.BAT puts what is typed next in environment variable INPUT
set input=
echo INPUT.BAT
echo Type in something and press [Enter]
fc con nul /lb1 /n|date|find " 1: ">temptemp.bat
echo :Loop>>enter.bat
echo if not (%%input%%)==() set input=%%input%% %%5>>enter.bat
echo if (%%input%%)==() set input=%%5>>enter.bat
echo shift>>enter.bat
echo if not (%%5)==() goto Loop>>enter.bat
for %%x in (call del) do %%x temptemp.bat
del enter.bat
echo The string you just entered:
echo %input%
echo has been stored in an environment variable named INPUT
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 430 Date: 07 May 96 19:02:00
From: Jeff Brielmaier Read: Yes Replied: No
To: Osgar Schaedtler Mark:
Subj: DETECT IF WINDOWS IS RUNN
──────────────────────────────────────────────────────────────────────────────
OS>Is there a way to detect, in a batch file, if Windows is running?
set|find "windir= >nul
if errorlevel 1 goto NotRunning
....Windows is running....
* KingQWK 1.05 # [PK] * DESQview vs. Windows is a no-Win situation.
-!- FLAME v1.1
! Origin: HAL-PC - (713)963-4100 (1:106/4100)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 431 Date: 05 May 96 10:08:00
From: Horst Schaeffer Read: Yes Replied: No
To: Vernon Frazee Mark:
Subj: ERRORLEVEL
──────────────────────────────────────────────────────────────────────────────
-=> quoting Vernon Frazee to Gary Smith (29 Apr 96) <=-
VF> [....]
VF> Applied the same technique to mine and it's now at 329 bytes:
VF> @echo off
VF> set F=for %%x in (
VF> set E=errorlevel|%F%A B) do set %%x=0 1 2 3 4 5
VF> [....]
Wow! But what shall I do with the rest of the 32Kb cluster?
Wouldn't it be more useful to have a routine that's simple and
easy to understand? For example:
@echo off
set !=
for %%h in (0 1 2) do if errorlevel %%h00 set EL=%%h
if not errorlevel 200 set !=6 7 8 9
for %%t in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%t0 set EL=%EL%%%t
if not errorlevel 250 set !=6 7 8 9
for %%u in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%u set EL=%EL%%%u
echo %EL%
set !=
set EL=
No fluff to save space ;-) ... and only 316 bytes.
VF> ..... displays errorlevels with leading zeros, mine does not
Would require minor modifications (+24 bytes) - but I prefer to
leave it as simple as it is.
Horst.
... Q4FM 2.10a ... horst@confusion.rmc.de
-!- FM 2.02 / ScanToss
! Origin: Don't follow leaders! (2:2480/13.75)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 12 May 96 23:40:02
From: Raphael Neve Read: Yes Replied: No
To: John Medland Mark:
Subj: deleteing the undeletable dir
──────────────────────────────────────────────────────────────────────────────
Following up a message from Malcolm Campbell to John Medland:
JM=> I had this problem a year or so ago and it's come back to haunt
JM=> me. Some one had given me a solution but I've lost the message
JM=> now. The problem:
JM=> A directory has been renamed using an illegal name.
JM=> Dos can't delete or rename the dir. No programs can delete it
JM=> either. It was named c:\max\cbv, but the name has been changed to
JM=> c:\max\cbv á. Anyone?
if you really want to get radical, you can always use a disk sector editor to
delete the file "by hand" :) seriously... all you have to do is:
a) load up your favourite sector editor
b) search for a distinguishing string (the directory name in question (CBV) or
any other file in the same directory... make sure you do all capitals
c) make sure you've got the right file / directory name
d) check again
e) kneel down in front of the computer and call upon the computer gods to
protect you
f) cross fingers and touch wood
g) replace the first character of the file or directory name by E5
h) make sure you don't change anthing else
h) save and quit
check you did it right by doing a dir. if you still see it and you're sure you
saved, then you've done something wrong and the results are unpredictable. if
you don't then you're well on your way to becoming a die-hard-disk-sector-
editor guru. then run scandisk to get rid of the lost clusters (ie all the
stuff that didn't get unlinked when you got rid of the directory or file
"manually")
note: kids, don't do this at home!!!
raph.
p.s. this is accurate: in a nutshell, dos recognises files that are deleted
from those that aren't by checking if the first character of a filename /
directory name is 'e5'. when you delete a file, all that happens is this
character gets written in the fat on top of the first character of the filename
(well, actually the associated clusters are freed too but that's nothing to do
with the fat). anyway... by writing this character in there yourself, you
effectively delete the file.
... Buy Stacker? Why not just delete Windows?
-!- FMail 0.96Γ
! Origin: Canada Dry BBS - France * 3 lines on 47.29.33.85 (2:321/1)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 14 May 96 20:15:46
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: errorlevel
──────────────────────────────────────────────────────────────────────────────
LN> Here's my 2 bits worth.
LN>
LN> ::ERR.BAT/DOS6.20
LN> :: Tested through errorlevel 26
LN> @echo off
LN> cls
LN> for %%h in (0 1 2) do if errorlevel %%h00 set L=%%h
LN> for %%t in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %L%%%t0 set L=%L%%%t
LN> for %%u in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %L%%%u set L=%L%%%u
LN> echo errorlevel=%L%
LN> set L=
LN> :L8r
LN>
LN> Less code, no temp files, 1 envar, and 280 bytes.
LN> :L8r
A measly 7 more bytes and you get 'em all:
@echo off
set e=Errorlevel|set !=|set p=for %%t in (0 1 2
%p%) do if %e% %%t00 set L=%%t
if not %e% 200 set !=6 7 8 9
%p%3 4 5 %!%) do if %e% %L%%%t0 set L=%L%%%t
if not %e% 250 set !=6 7 8 9
%p%3 4 5 %!%) do if %e% %L%%%t set L=%L%%%t
set !=|set L=|set e=|set p=|echo %e%=%L%
<g>
-!- Terminate 4.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 441 Rec'd Date: 22 May 96 18:04:53
From: Vernon Frazee Read: Yes Replied: No
To: Bat Lang Mark:
Subj: FOR/DO... Clean and Conc
──────────────────────────────────────────────────────────────────────────────
VF> for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
VF> If you'll watch DOS process this line, you can see it doing
VF> exactly the same thing as the above four individual lines
VF> SET TEMP=C:\TEMP
VF> SET TMP=C:\TEMP
VF> SET LIST=C:\TEMP
VF> SET AHDTMP=C:\TEMP
BL> Which is faster in execution, your first quoted line, or?:
BL> SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
To slow them down enough to be able to even time them, I did 10
iterations of each. IOW,
@echo off
:FORINDO.BAT
for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
... 10 of these for-in-do's ...
@echo off
:SET-EACH.BAT
SET TEMP=C:\TEMP
SET TMP=C:\TEMP
SET LIST=C:\TEMP
SET AHDTMP=C:\TEMP
set temp=c:\temp
set tmp=c:\temp
set list=c:\temp
set ahdtmp=c:\temp
SET TEMP=C:\TEMP
SET TMP=C:\TEMP
SET LIST=C:\TEMP
SET AHDTMP=C:\TEMP
... 10 sets of these groups of four ...
@echo off
:ALLON1.BAT
SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
... 10 of these lines ...
I then ran each 10 times and averaged the elapsed times. Results:
BATch file Elapsed Time
------------ -------------
FORINDO.BAT 1:59 seconds
SET-EACH.BAT 1:37 seconds
ALLON1.BAT 10:99 seconds
Yep, I couldn't believe it either. <G>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 419 Date: 23 May 96 16:49:56
From: Vernon Frazee Read: Yes Replied: No
To: Jesse Block Mark:
Subj: Bat Needed!
──────────────────────────────────────────────────────────────────────────────
JB> The other day, we were tring to make a Batch file that would comb
JB> through an ASCII file and pullout all the web address, then, put
JB> them into another ASCII file called NET.TXT. We found this could
JB> do it from MS_DOS 6.22:
JB>
JB> for %f in (*.txt) do find "http:" %f > net.txt
JB>
JB> but for some reason, we couldn't use this in a batch file. It kept
JB> coming back "syntax error" but it worked fine from a dos prompt. So,
JB> here's my problem:
JB>
JB> 1. Can this be done as a batch file in a different way?
JB>
JB> 2. What did I do wrong that _this_ wouldn't work?
DOS strips one of the percent signs when for-in-do is being used in
a BATch file. Therefore, if you'll change both occurances of "%f"
to "%%f" it should work just fine.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 407 Date: 23 May 96 10:24:40
From: Richard Epling Read: Yes Replied: No
To: Alan Milewczyk Mark:
Subj: Capturing date in a batch
──────────────────────────────────────────────────────────────────────────────
From: Alan Milewczyk Time: 05-19-96 13:30:30
> I want to be able to capture today's date into a batch file to enable
> me to copy files in a specific directory with the attribute flag set.
> How do I capture the date and pass it over to the copy file routine.
I don't understand how you would use the date to copy the files but I'm
assuming you do. One way you could do this would be to get the output of a
DATE command into a temporary batch file which you could then use to run
another batch file to do what you want to do. For example;
@ECHO OFF
ECHO.|DATE|FIND /I "CURRENT">TEMP.BAT
That will put the line "Current date is Thu 05-23-1996" into TEMP.BAT.
You can then either have a batch file name CURRENT.BAT to do the work, and
CALL TEMP.BAT or ECHO the commands you want to CURRENT.BAT. For example to
set an environment variable with the current date you could continue the
above example with these lines;
ECHO SET D8=%%4>CURRENT.BAT
CALL TEMP.BAT
That will give you an environment variable you might be able to use in your
other batch command. Note the double percent sign is required here. The
contents of CURRENT.BAT would be "SET D8=%4." CALLing TEMP.BAT would cause it
to run CURRENT.BAT which would set the variable for you. Hope this is what you
need.
Richard
-!- FreeMail 1.09
! Origin: Electric Eye-28.8 Sacramento,CA(916)441-5465 (1:203/65)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 449 Date: 27 May 96 00:00:00
From: Mike Zeleski Read: Yes Replied: No
To: Robin Chapple Mark:
Subj: Where To Start?
──────────────────────────────────────────────────────────────────────────────
RC>Greetings To All!
RC> I'm wanting to learn more about batch file programming.
RC> Where does a 'know nothing' start?
With the basics... :-}
RC>Is there a file I can download?
Several, notably you should look for MUF17, and any one of several Batch
programming tutorial that exist on the Nets...
RC>Is there a good book that I can buy?
Several, however you should already have a good one already...
Your Dos Manual, and the Dos Help program. While they are not
particularly batch specific, they will help a lot.
The other features of BFP are not all that bad to master.
Excluding ordinary Dos commands, BFP just adds a few instructions,
labels, and variables to the mix...
Lets see...
%1-%9 are handled much like Dos command line variables,
There is a IF (?) command, Labels to go to, and several other bits...
See below for a few examples. This little bit is notoriously short on
how to's beyond the vary basic minimums, but frankly let's discuss them
later when you have specific questions to ask...
[Start Mike's BFP MiniFaq.]
Batch file program is based on the simple conjecture that it is easy to
create a user readable text file program/utility that simply stacks Dos
commands together with just a few special BFP commands to do actions
like move a file or create a directory and move to it without having to
create a program to do so from scratch...
This can be a simple way to automate anything that you do more than
once. With a few external Batch programming aids, the use of command
line variables, internal variables, Qbasic calls, stacked commands,
errorlevel jumps, Labels, and Goto's these "little" programs can get
quite sophisticated and complicated in a hurry.
However BFP is best when kept to the basics for most mundane everyday
uses, as in good engineering KISS is the word. As a tip I often use a
little batch file that dumps doskey's remembered commands into a little
batch file and immediately edit it like so.
Qckbat.bat (Use D:\path\xxxxxxxx.bat CM parameter)
DOSKEY /HISTORY > %1
EDIT %1
This little example dumps past instructions into a batch file and
immediately sends you into edit to make some small changes to that
batch file. (You must have doskey loaded to make this work.)
I also used a Batchfile program to present a nice menu with ansi.sys
commands and a external utility to run my most frequently used programs
from. I did this to even run some Windows programs or plain Windows by
itself. Did you know that you can start Windows and run a Windows program
immediately from the commandline...
In fact here are a few clips from that menu, (If you want the entire
thing including the utility I used to use, Netmail me.) One of the
below clips includes the most efficient defrag command line I know of.
It's only a few percent better than a simple consolidation, but what the
hay, you might as well do it right...
[quote mode on.]
:run_defr
C:\d\defrag C: /F /S:E
goto restart2
:run_qmdm
win c:\qmpw\qmwin qmwin.phn 1
rem This little string starts Windows, my old Q-modem terminal program,
rem calls my main bbs mail #, and it's attached script. Mail run.
rem Automation! 3 command line parameters for two different programs.
goto restart
:winstart
win
rem Run Windows.
goto restart
:wp_60
win C:\wp60\wp
rem Same as above with Word Perfect 6 for windows.
goto restart
:win_word
win C:\winword\winword.exe
Rem Yes, I do Microsoft apps. But you should hear the wave file attached
rem to this program's start up it. Ahooga.wav
goto restart
:Gramtx_5
Win: c:\gmkw\gmkw.exe
rem sometimes we use bad english, don't we...
goto restart
[quote mode off.]
Some other useful examples...
MDCD.BAT (Use xxxxxxxxxxx directory name CM param.)
MD %1
CD %1
This little BFP creates the directory and moves you directly into the
directory that it just created. Use just like you would use both MD &
CD, but it combines them into just one command...
Header.bat (Use D:\path\xxxxxxxx.txt CM parameter.)
@Echo (One line of text here) > JUNK.txt
copy JUNK.TXT + %1 %1
del junk.txt
This little installs adds one line of prespeficified text into the
beginning of every file indicated as the commandline parameter.
If you want to add more than one line then you do it this way...
Header.bat (Use D:\path\xxxxxxxx.txt CM parameter.)
@Echo (One line of text here) > JUNK.txt
@Echo (Next line of text here) >> JUNK.txt
Rem Repeat the echo as many times as needed.
rem One arrow means make the file, two means add to it, aka append.
copy JUNK.TXT + %1 %1
del junk.txt
Trailer.bat
@Echo (One line of text here) > JUNK.txt
@Echo (Next line of text here) >> JUNK.txt
Rem Repeat the echo as many times as needed.
rem One arrow means make or overwrite the file, two means add to it, aka
rem append.
copy %1 + JUNK.TXT %1
del junk.txt
There are some good BFP FAQ/tutorial files floating around out on the
BBS's, as is the excellent MUF 1.7 file. I suggest you grab them...
-!-
* OLXWin 1.00b * Always tell her she's beautiful, especially if she isn't. RAH
-!- WILDMAIL!/WC v4.12
! Origin: Father & Son*610-439-1509*Whitehall Pa (1:2607/112.0)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 30 May 96 09:04:27
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Errlevel.exe
──────────────────────────────────────────────────────────────────────────────
VF> I almost sent you the following little ERRLEVEL.COM (& .DOC) in my
VF> last message to you. It sticks whatever errorlevel you want in
VF> memory so you can then test for it with your BATch file.
VF> ----------------------------->CUT HERE<-----------------------------
VF> NERRLEVEL.ZIP
LN> TKS, Rat.com worked but it was a long way around. Am now waiting for
LN> the sh*t storm when these guys discover that we might actualy stoop
LN> to extraDOS utilities on the odd occation.
<g>
LN> Has any body actualy found where in memory the errorlevel data is
LN> stored?
Here, try this -- stick an exit code in memory that can then be
tested for with one of the EL.BAT files floating around:
1) Put what's in this Everything in this column
column into a file is merely a comment and
named GETKEY.SCR: should not be in the file
------------------ ----------------------------
N GETKEY.COM Filename will be GETKEY.COM
A Toggle into assembler mode
MOV AH,00 BIOS read a character and
INT 16 put its ASCII code into AL
MOV AH,4C Ready to exit with code so
INT 21 do it
Toggle out of assembler mode
RCX Read register CX and
8 stuff file size into it
W Write the file to disk
Q Quit DEBUG
(Note: Make sure you leave the blank line between "INT 21" and "RCX"
to toggle DEBUG back out of the assembler mode).
2) Create the program GETKEY.COM by typing:
DEBUG<GETKEY.SCR
3) To test it type:
GETKEY|EL
and then press say the [Esc] key. You should get an errorlevel
of 27 -- the ASCII code for the Escape character. Now try it by
pressing say [Shift-A] (uppercase A) and you should get an
errorlevel of 65. Lowercase "A" would be 97, etc., etc., etc.
Or, you could even use it in a BATch file that would only exit to
DOS if you pressed say the [Enter] key (ASCII 13):
@echo off
echo Press the [Enter] key to exit to DOS
:Loop
getkey
if errorlevel 13 if not errorlevel 14 goto End
goto Loop
:End
(Note: Both DOS and your system's BIOS can process keystrokes. This
particular example uses the BIOS but it's just as easy to substitute
a DOS function call. In fact, DOS is better for some things because
it offers several options. It can display the character you entered
or discard it, wait for a keystroke or process one only if it's
there waiting, and it can handle break attempts or ignore them).
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 439 Date: 30 May 96 14:27:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: filenames with numerical extensions
──────────────────────────────────────────────────────────────────────────────
If anybody has a series of files with all digit extensions, I
made the following two batch files to enable switching back
and forth between having or stripping leading zeroes in their
extensions (i.e., renaming the files by changing the extension).
These batch file names may be called whatever_you_want.bat
Rejoin word-wrapped command sentences at the dollar signs, then
delete the dollar signs.(Two sets per file)
------------------------------------------------
::lead000.bat
@echo off
if "%1"=="pancakedough" goto pancakedough
if "%1"=="" goto syntax
set fn=%1
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.%%x ren %fn%.%%x %fn%.00%%x
for %%x in (0 1 2 3 4 5 6 7 8 9) do call %0 pancakedough %%x
goto end
:pancakedough
set k=%2
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.%k%%%x ren %fn%.%k%%%x %fn%.0%k%%%x
goto end
:syntax
echo enter lead000 file_basename
:end
set k=
------------------------------------------------
------------------------------------------------
::nolead0.bat
@echo off
if "%1"=="pancakedough" goto pancakedough
if "%1"=="" goto syntax
set fn=%1
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.00%%x ren %fn%.00%%x %fn%.%%x
for %%x in (0 1 2 3 4 5 6 7 8 9) do call %0 pancakedough %%x
goto end
:pancakedough
set k=%2
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.0%k%%%x ren %fn%.0%k%%%x %fn%.%k%%%x
goto end
:syntax
echo enter nolead0 file_basename
:end
set k=
------------------------------------------------
For example, if you have file.1 through file.25, entering
a command of lead000 file will leave you with file.001
through file.025. To put them back to original names,
enter nolead0 file
Roy
! Origin: The GIFfer BBS, 75+gig, (813)969-2761 (1:377/50)
TOP
##############################################################################
─ Area: Batch Language Programming FI ────────────────────
Msg#: 423 Date: 27 Feb 96 23:40:00
From: Vernon Frazee Read: Yes Replied: No
To: Furlan Primus Mark:
Subj: L-O-N-G PATH 1/2
──────────────────────────────────────────────────────────────────────────────
VF> BTW, I have shown more than a few folks how a PATH of up to at least
VF> 4,096 bytes (yep, that's four-thousand-and-ninety-six characters)
VF> can be created and successfully used... using nothing more than DOS.
FP> i have always kept my PATH to the mininum needed as a matter of
FP> choice
Same on this end (it's faster).
FP> and just exactly HOW do you do the above anyway???
--------------------------------------------------------------------
L-o-n-g PATH "how to" for MS-DOS version 6.nn (any version of DOS 6)
--------------------------------------------------------------------
Normally, on most MS-DOS v6.xx systems, when the system boots it
looks for and loads/runs the following five files -- in this order:
1) IO.SYS - basic Input/Output routines
2) MSDOS.SYS - basic MicroSoft Disk Operating System routines
3) CONFIG.SYS - user created ASCII file (drivers, etc.)
4) COMMAND.COM - command line processor
5) AUTOEXEC.BAT - user created ASCII file (whatever)
The 4th step, loading COMMAND.COM, is what limits the command line,
and hence the "PATH=..." line length in AUTOEXEC.BAT, to a maximum
of 127 characters.
The 'secret' to creating a l-o-n-g PATH then is to set it up in
CONFIG.SYS -- before COMMAND.COM's 127 character line limit has
come in to play -- instead of in AUTOEXEC.BAT.
Setting up a PATH in CONFIG.SYS only works, (I believe), in MS-DOS
v6.xx or higher and uses the following syntax:
SET PATH=drive:\directory[;drive:\directory][;...]
Tip: All of the following examples will NOT work in CONFIG.SYS like
they do in AUTOEXEC.BAT:
PATH=... PATH=%PATH%;... SET PATH=%PATH%;...
PATH ... PATH %PATH%;... SET PATH %PATH%;...
In other words, if the line doesn't begin with "SET PATH=", DOS
will return something like "Error in CONFIG.SYS line 1".
The %PATH% idea also fails because the program that defines and
understands such, COMMAND.COM, has not been loaded yet.
PATH lengths of up to a whopping 4,096 characters have been tested
here, with success, using this "CONFIG.SYS" "SET PATH=..." approach.
--------------------------------------------------------------------
[ ... text deleted for brevity ... ]
-!-
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 431 Date: 04 Mar 96 13:28:05
From: Vernon Frazee Read: Yes Replied: No
To: Carlo Mosti Mark:
Subj: Daily execution
──────────────────────────────────────────────────────────────────────────────
CM> I would like to know if someone knows of a way to resolve my problem
CM> by using only batchfile commands. I want to execute a program
CM> everyday but only once! How do I control that?
Here's one that does it by storing the command you entered plus the
current system date on one line at the end of the BATch file itself.
When you launch it again it simply looks for an identical command-
line/date. (If one is found it tells you that command has already
been run today. If no match is found, it adds the command and date
to the end of the file and continues).
Note: Because this is a self-modifying BATch file, you may need to
change all occurances of "C:\BAT" to the location of where you
intend on keeping it on your hard drive.
@echo off
:ONCEADAY.BAT runs a specified program once-a-day only -----------------
:Notes: This BATch file is self modifying! It keeps track of every date
: and the command(s) issued on that date at end of this file.
: Requires DOS's FIND (somewhere in current PATH is fine).
: Use "CURRENT /C" (not the quotes) to clear all dates from file.
:-----------------------------------------------------------------------
if (%1%2)==(dateis) goto GOTIT
if (%1)==(/?) goto SYNTAX
if (%1)==() goto SYNTAX
for %%x in (:) do set colons=%%x%%x
for %%x in (c C) do if (%1)==(/%%x) goto CLEAR
set program=%1 %2 %3 %4
ver|date>temptemp.bat
echo %0 %%1 %%2 %%3 %%4>current.bat
temptemp
:GOTIT -----------------------------------------------------------------
set date=%4
find /c "%colons%%4%program%" C:\BAT\%0.BAT>temptemp.bat
echo set current=%%2>--------.bat
call temptemp.bat
if (%current%)==(0) echo %colons%%date%%program%>>C:\BAT\%0.BAT
if (%current%)==(0) goto DO_IT
echo Command: %program%
echo has already been run today.
goto CLEANUP
:DO_IT -----------------------------------------------------------------
cls
echo Issuing command: %program% ...
echo.
call %program%
goto CLEANUP
:CLEAR -----------------------------------------------------------------
type C:\BAT\%0.BAT|find /v "%colons%">C:\BAT\%0.BAT
:CLEANUP ---------------------------------------------------------------
for %%x in (-------- temptemp current) do if exist %%x.bat del %%x.bat
for %%x in (program colons current date) do set %%x=
goto END
:SYNTAX ----------------------------------------------------------------
cls
echo.
echo Name: ONCEADAY.BAT
echo.
echo Author: Vernon Frazee 03/03/94
echo.
echo Purpose: Run specified command only once a day.
echo.
echo Syntax: ONCEADAY program_name/command [parm_1] [parm_2] [parm_3]
echo.
echo ONCEADAY /C clears all entries
echo.
echo ONCEADAY /? displays this help
echo.
echo Example: ONCEADAY DEFRAG C: /F /SN
echo.
echo Notes: Requires DOS's FIND (must be available in current PATH)
echo.
echo Requires at least approx 50 bytes free environment space
echo.
echo ONCEADAY.BAT is self modifying! (It keeps track of when
echo and what was run at the end of the file).
echo.
goto END
:END (Data storage begins below) --------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 390 Date: 04 Mar 96 21:52:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: Counting file lines
──────────────────────────────────────────────────────────────────────────────
LD>> I want this batch to make a list of %1 <EG: *.bat or *.txt>
LD>> then use the list to count the lines in each found
LD>> then report to some file, the found file name(s) and the # of
lines
LD>> EG: somefile.txt 27
LD>> othrfile.txt 13
LD>> yetnothr.txt 29
I used SORT and FIND from DOS, and Michael Mefford's CHANGE.COM in the
following batch file to group extension_requested files of the current
directory in a list and count their lines.
After running this file 12 times, you'll get a file creation error on
the 13th run. Anybody know why? Something with the FIND command
or FOR IN DO or CALL? My el cheapo 486?
If I change the do find in the for-in-do to do call find, it bombs on
the 9th try.
REM countext.bat
@echo off
if "%1"== "" goto syntax
set fn=-%1
if exist $!&)list del $!&)list
for %%x in (*.%1) do find /c /v "<^>#~" %%x >>$!&)list
call change $!&)list 13,10,45,45,45,45,45,45,45,45,45,45 "" > nul
call change $!&)list ":" "" > nul
call sort < $!&)list > %fn%list
del $!&)list
set fn=
goto end
:syntax
echo.
echo enter countext ext of filenames you want linecounts of
echo example - countext txt, or countext doc, or countext bat, etc.
echo filenames and linecounts will be in file -extlist
:end
::---------------RCR--------------
Part 1
-!- PCBoard (R) v15.22 (OS/2) 10
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 391 Date: 04 Mar 96 21:54:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: Counting file lines
──────────────────────────────────────────────────────────────────────────────
Here is another version named extcount.bat using PREFIX.COM
from DOSWORLD magazine.
@echo off
if not "%4"== "" goto wrapitup
if "%1"== "almost_done" goto shrink
if "%1"== "" goto syntax
set fn=-%1
if exist $!&)list.bat del $!&)list.bat
if exist %fn%list del %fn%list
for %%x in (*.%1) do call %0 almost_done %%x
call sort < %fn%list > po-trait
del %fn%list
ren po-trait %fn%list
for %%y in (fn name) do set %%y=
goto end
:wrapitup
echo %name% %4 >> %fn%list
if exist $!&)list.bat del $!&)list.bat
goto end
:shrink
set name=%2
echo. | find /c /v "<^>#~" %name% | find "----------" | ...
... prefix extcount plop >>$!&)list.bat
call $!&)list
goto end
:syntax
echo enter extcount and extension of files you want individual count of
:end
::---------------RCR--------------
In extcount.bat, assemble the two lines with ... together at that point
Here is the PREFIX.SCR to DEBUG < PREFIX.SCR to obtain prefix.com
N PREFIX.COM
A
PUSH CS
POP DS
MOV DX,0157
MOV [0155],DX
MOV AH,3F
MOV BX,0000
MOV CX,0001
MOV DX,[0155]
INC WORD PTR [0155]
INT 21
CMP AX,0000
JNZ 0125
MOV AX,4C00
INT 21
PUSH DX
POP SI
MOV AH,[SI]
CMP AH,0A
JZ 0130
JMP 0109
PUSH AX
MOV BX,0001
XOR CH,CH
MOV CL,[0080]
MOV DX,0081
MOV AH,40
INT 21
MOV AH,40
MOV BX,0001
MOV CX,[0155]
SUB CX,0157
MOV DX,0157
INT 21
JMP 0102
RCX
155
W
Q
Try, for example; DIR |prefix put me first >> zzz
Part 2
-!- PCBoard (R) v15.22 (OS/2) 10
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 392 Date: 04 Mar 96 21:55:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: COUNTING FILE LINES
──────────────────────────────────────────────────────────────────────────────
This will count the lines in one file. Submitted to see how badly
Vernon Frazee will "in my face" me with his faster two-liner. But
I do honor the king.
@echo off
if "%2"=="felines" goto felines
if "%1"=="" goto namepls
set fn=%1
find /c /v "<^>#~" %1 > (^^--^^).bat
call change (^^--^^).bat 13,10,45,45,45,45,45,45,45,45,45,45 "felines
felines felines" > nul
echo.
(^^--^^) > nul
:felines
echo file %fn% has %4 lines
goto end
:namepls
echo proper syntax is felines filename
echo this finds # of lines in named file
:end
set fn=
del (^^--^^).bat
-!- PCBoard (R) v15.22 (OS/2) 10
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 424 Date: 05 Mar 96 09:17:01
From: Vernon Frazee Read: Yes Replied: No
To: Stephan Hoppe Mark:
Subj: Get date?
──────────────────────────────────────────────────────────────────────────────
SH> What I'd like to do is have a plain vanilla batch file that grabs
SH> the day of the month so that on the 3rd, for example, I could defrag
SH> my HD, on the 4th run scandisk, etc. etc.
SH> I figure it would have to be something that grabs the day of the
SH> month as an env variable then the calling batch files would check
SH> this to see if its the right day.
SH> How to grab the variable?
SH> Please no 4dos, ndos or whatever. . .just MS-DOS.
Here's one way to get the current system Month, Day, and Year, into
separate environment variables (evars) using DOS's CHOICE.COM.
@echo off
:---------------------------------------------------
: Name: MDY.BAT - For US DATE format (mm-dd-yyyy)
: Purpose: Using current system date, put 2-digit
: month in evar MM, 2-digit day in evar DD,
: and 2-digit year in evar YY.
:Requires: CHOICE.COM and 36 bytes in environment.
:---------------------------------------------------
if (%1)==(![) goto ParseIt
for %%x in (mm dd yy mdy) do set %%x=
>~tmp~.bat ver|date
echo set mdy=%%4>current.bat
for %%x in (call del) do %%x ~tmp~.bat
del current.bat
>~tmp~.bat echo;;|choice/c:;%mdy%; "%0 !"
~tmp~.bat
:ParseIt -------------------------------------------
set mm=%2%3|set dd=%5%6
shift|shift
set yy=%8%9|echo MM=%mm%
echo DD=%dd%
echo YY=%yy%
del ~tmp~.bat|set mdy=
:End ----------------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 428 Date: 05 Mar 96 03:38:00
From: Vernon Frazee Read: Yes Replied: No
To: Richard Dale Mark:
Subj: Humongous project
──────────────────────────────────────────────────────────────────────────────
RD> M:\USERS\74801000>fwcopy 74801000 phone.001
VF> The enclosed examples should help you get started
RD> I thank you very kindly! I shall let you know on the results.
You're more than welcome, and yes, please do.
RD> FWIW, "fwcopy" copies the files over to be used by the Ft. Worth
RD> office, hence "fw". The command that is *really* supposed to be
RD> used is CLEAN 74801000 PHONE.001, but if I mess up and clean
RD> PHONE.001 again within 5 minutes or so, it can crash or slow down
RD> the system. Sheesh!<tm>.
The following might help solve that particular problem. It only
allows the exact same command to be run once per day.
@echo off
:ONCEADAY.BAT runs a specified program once-a-day only -----------------
:Notes: This BATch file is self modifying! It keeps track of every date
: and the command(s) issued on that date at end of this file.
: Requires DOS's FIND (somewhere in current PATH is fine).
: Use "CURRENT /C" (not the quotes) to clear all dates from file.
:-----------------------------------------------------------------------
if (%1%2)==(dateis) goto GOTIT
if (%1)==(/?) goto SYNTAX
if (%1)==() goto SYNTAX
for %%x in (:) do set colons=%%x%%x
for %%x in (c C) do if (%1)==(/%%x) goto CLEAR
set program=%1 %2 %3 %4
ver|date>temptemp.bat
echo %0 %%1 %%2 %%3 %%4>current.bat
temptemp
:GOTIT -----------------------------------------------------------------
set date=%4
find /c "%colons%%4%program%" C:\BAT\%0.BAT>temptemp.bat
echo set current=%%2>--------.bat
call temptemp.bat
if (%current%)==(0) echo %colons%%date%%program%>>C:\BAT\%0.BAT
if (%current%)==(0) goto DO_IT
echo Command: %program%
echo has already been run today.
goto CLEANUP
:DO_IT -----------------------------------------------------------------
cls
echo Issuing command: %program% ...
echo.
call %program%
goto CLEANUP
:CLEAR -----------------------------------------------------------------
type C:\BAT\%0.BAT|find /v "%colons%">C:\BAT\%0.BAT
:CLEANUP ---------------------------------------------------------------
for %%x in (-------- temptemp current) do if exist %%x.bat del %%x.bat
for %%x in (program colons current date) do set %%x=
goto END
:SYNTAX ----------------------------------------------------------------
cls
echo.
echo Name: ONCEADAY.BAT
echo.
echo Author: Vernon Frazee 03/03/94
echo.
echo Purpose: Run specified command only once a day.
echo.
echo Syntax: ONCEADAY program_name/command [parm_1] [parm_2] [parm_3]
echo.
echo ONCEADAY /C clears all entries
echo.
echo ONCEADAY /? displays this help
echo.
echo Example: ONCEADAY DEFRAG C: /F /SN
echo.
echo Notes: Requires DOS's FIND (must be available in current PATH)
echo.
echo Requires at least approx 50 bytes free environment space
echo.
echo ONCEADAY.BAT is self modifying! (It keeps track of when
echo and what was run at the end of the file).
echo.
goto END
:END (Data storage begins below) --------------------------------- -vjf-
RD> Thanks again.
No problem. Let me know how you make out.
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 430 Date: 06 Mar 96 18:32:00
From: Vernon Frazee Read: Yes Replied: No
To: Larry Kwiatkowski Mark:
Subj: Caps in ENV
──────────────────────────────────────────────────────────────────────────────
WE> you need a lot of if-statements to ask for all possiblities ...
WE> set variable=example
WE> set variable=Example
WE> set variable=EXAmple
WE> It would be much easier if I could change the content of an
WE> environment variable to either small or capital letters.
LK> I use a rather complicated routine to do exactly that - map the file
LK> names to all caps - using GET.EXE and QEDIT. I hope there is some
LK> simpler way to accomplish mapping to all caps. Does anyone have a
LK> workable solution?
Here's a fairly simple "COMMAND.COM only" example:
@echo off
:---------------------------------------------------
:UP-CASE.BAT - UPPERcases user parameters
: (up to about 49 characters)
: For example: up-case WiLe e cOyOtE
: returns: WILE E COYOTE
: Note: Results stored in evar UP-CASE
:---------------------------------------------------
if (%1)==() goto End
path>~savpath.bat
for %%x in (up-case path) do set %%x=
:Loop ----------------------------------------------
path %1
if not (%up-case%)==() set up-case=%up-case% %path%
if (%up-case%)==() set up-case=%path%
shift
if not (%1)==() goto Loop
echo %up-case%
for %%x in (call del) do %%x ~savpath.bat
:End ----------------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 402 Date: 08 Mar 96 23:14:04
From: Dennis Mccunney Read: Yes Replied: No
To: Greg Paksi Mark:
Subj: Two OS's on one drive?
──────────────────────────────────────────────────────────────────────────────
** From Greg Paksi to Brian Altenpohl on 29 Feb 96 16:53:54
** Re: Two OS's on one drive?
BA> Also, you may want to take a look into QNX, it is a great O/S, and
BA> comes with the QNX loader, which will allow you up to 4 different OSs
BA> on a single machine. Perhaps newer version of QNX will allow more.
BA> Or you could write a simple Boot-Manager program - it isn't very
GP> What's QNX? How is it different than DOS, UNIX, OS/2, WINDOWS NT,
GP> etc.?
QNX is an operating system from a company in Canada called QNX
(formerly known as Quantum). It began as a UNIX-like OS optimised to
run on Intel CPUs (and would run reasonably on XTs and well on ATs).
It has evolved into an OS aimed at the real-time market, with built-in
network awareness.
-!- Blue Wave/DOS v2.30
! Origin: * BlueDog BBS * (212) 594-4425 * NYC FileBone Hub (1:278/304)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Local Date: 11 Mar 96 18:30:57
From: Bat Lang Read: Yes Replied: No
To: Steve Meech Mark:
Subj: Copying files
──────────────────────────────────────────────────────────────────────────────
-=> Quoting Steve Meech to All, [09 Mar 96 00:29:06] <=-
SM> Anyway, back on topic, the problem is that I have to transfer 13Mb of
SM> files, many of which don't change from one day to the next.
SM> Is there a way of copying only those files which are _different_ on
SM> the two machines, to save time (in the way PKZIP's "update" function
SM> does).
SM> I'd be interested in a batch-file or utility solution.
^^^^^^^^^^^^^^^^^^^
There is a nifty util in the BFDS files called DIRCOMP:
DIRCO511.ZIP 117060 12-18-95 DIRCOMP.EXE (5.11): Updates files in one
subdirectory based on files in another
subdirectory. Similar in some ways to DOS's
REPLACE command
Here is a batch file I use with this to maintain a portable
parallel-port hard drive (Gator) as a mirror of another drive on my
system.
::UPD.BAT to compare two dirs, and kill dir2 files not in dir1 & copy
:: dir1 files to dir2 that are more recent, or not in dir2.
@echo off
CP /T:N,10 Do you want the Gator UpDated?
if %EL% 2 goto end
dirco k: l: /KILL /APPEND /-I
:end
Saves me MANY hours each month, and hasn't messed up yet. Also
maintains a log of it's activities. The second line uses Chad's Choice
Plus (CP102). Could use CHOICE or leave it out.
Note: The %EL% is a shortcut allowed by my inclusion of:
SET EL=ERRORLEVEL ;in my AEBat file.
If your DOS includes REPLACE, you might get it to do your bidding?
I also renamed the DIRCOMP.EXE so it looks like the archive name.
Good Modeming! /\oo/\
... NetMail: 1:382/1201 or E-mail: bat.lang@1201.ima.infomail.com
-!- Blue Wave/Max v2.30
! Origin: The HUB * Austin TX * Centex PCUG * 512-346-1852 (1:382/1201)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 11 Mar 96 12:47:00
From: Gottfried Hommon Read: Yes Replied: No
To: STEPHAN HOPPE Mark:
Subj: Sloppy batch file
──────────────────────────────────────────────────────────────────────────────
----------------------------------------- Vienna, the 11.Mar.1996 at 12.46
Hi STEPHAN!
29-Feb-96 19:35, STEPHAN HOPPE wrote to ALL
Subject: Sloppy batch file
SH> Is there any way of making this a little less bulky?
>>>>>GETDAY.BAT
SH> @echo off
SH> REM the line below returns the day of the month as an errorlevel. . .
SH> c:\utility\1tellme.exe day
SH> if errorlevel 1 if not errorlevel 2 set Today=1
SH> if errorlevel 2 if not errorlevel 3 set Today=2
SH> .
SH> if errorlevel 31 if not errorlevel 32 set Today=31
^^^^^^^^^^^^^^^^^^^^
is not necessary
do this:
for %%f in (1 2 3 4 5 6 7 8 9 10 11 12 13) do if errorlevel %%f set Today=%%f
for %%f in (14 15 16 17 18 19 20 21 22 23) do if errorlevel %%f set Today=%%f
for %%f in (24 25 26 27 28 29 30 31) do if errorlevel %%f set Today=%%f
with friendly greetings
from Gottfried Hommon
-!- Terminate 1.50/Pro
! Origin: ---------------> NOVELL DOS 7.15 USER <--------------- (2:310/65.78)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 12 Mar 96 05:49:03
From: Vernon Frazee Read: Yes Replied: No
To: Scott Farrell Mark:
Subj: File_id.diz
──────────────────────────────────────────────────────────────────────────────
MC> Check a zip file to see if it has a file_id.diz. if not then open
MC> the editor (ide.exe) which produces a file_id.diz in its own
MC> directory then this has to be inserted in the zip that was
MC> checked. If the file has a file_id.diz then continue to check the
MC> next zip.
SF> Have you got a solution to this?
Stick the following simple BATch file in some directory in
your PATH. (I keep my BATch files in "C:\BAT" for example).
@echo off
:ZIPID.BAT
pkunzip %1 file_id.diz
if errorlevel 11 goto End
edit file_id.diz
pkzip %1 file_id.diz
del file_id.diz
:End
Now change to the drive:\directory containing the ZIP files you
want to work on and type the command:
for %x in (*.zip) do call zipid %x
That's it.
Each ZIP file in your current directory will be checked for the
presence of a FILE_ID.DIZ file. If it exists, ZIPID.BAT file simply
exits (and then the for-in-do command above re-launches it with a
new filename.ZIP). If a FILE_ID.DIZ didn't exist, DOS EDIT is
launched so you can create one. When you exit EDIT, PKZIP adds your
new FILE_ID.DIZ to the filename.ZIP file just checked, your
FILE_ID.DIZ is deleted, and ZIPID.BAT exits back to DOS. And, when
the for-in-do is done presenting all the filename.ZIPs to ZIPID.BAT,
all your ZIP files should contain a FILE_ID.DIZ.
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 13 Mar 96 9:49:00
From: Horst Schaeffer Read: Yes Replied: No
To: Paul Emmons Mark:
Subj: Scripting programs
──────────────────────────────────────────────────────────────────────────────
-=> quoting Paul Emmons to All (7 Mar 96) <=-
PE> [...]
PE> Could anyone describe the basic techniques or algorithms which
PE> these various systems use?
-+-+- quote from Richard Marks' UUencode/UUdecode package:
The basic scheme is to break groups of 3 eight bit characters (24 bits)
into 4 six bit characters and then add 32 (a space) to each six bit
character which maps it into the readily transmittable character.
Another way of phrasing this is to say that the encoded 6 bit
characters are mapped into the set:
`!"#$%&'()*+,-./012356789:;<=>?@ABC...XYZ[\]^_
for transmission over communications lines.
As some transmission mechanisms compress or remove spaces, spaces are
changed into back-quote characters (a 96). (A better scheme might be
to use a bias of 33 so the space is not created, but this is not done.)
Another newer less popular encoding method, called XX-encoding uses the
set: +-01..89ABC...XYZabc...xyz
In my opinion, XX-encoding is superior to UU-encoding because it uses
more "normal" characters that are less likely to get corrupted. In
fact several of the special characters in the UU set do not get thru an
EBCDIC to ASCII translation correctly.
-+-+- unquote
PE> 256^4 = 4.294968E+09, and 85^5 = 4.437053E+09. Therefore, four
PE> binary bytes could be encoded into five ascii characters using any
PE> 85 of the ascii values between 32 and 127. Although I haven't
PE> tried implementing this in assembler, I would guess that
PE> recovering the original binary file from such a script would fit
PE> the architecture and instruction set of the 86 processors easily,
PE> i.e. the necessary code could be given in a short enough debug
PE> script header.
For a range of 85 you would need 32 bit multiplications. No big problem
even for a 8086, but the DEBUG header will become a little larger.
Main problem is to define a set of 85 characters that is safe enough
for FIDO mails. I'm not sure which characters between 31 and 127 have
to be definitely excluded to avoid problems.
PE> Probably others have thought of this principle or a better one, so
PE> there is no point in re-inventing the wheel if it has been done. I
PE> would like to know how Chad's and Horst's encoding systems work,
PE> but the answer is not obvious from the scripts they produce.
I think everyone used the simple method of shifting 4*6 bits out of
24. The idea of using a range other than 2^n is a very interesting
approach indeed.
However a ratio of 5/3 (vs. 4/3) would make scripts only 6.25% smaller
(not counting the overhead), and in zipped mail packages it will
probably make no difference at all.
Is is worth introducing a new standard?
Horst.
... Q4FM 2.10 ... horst@confusion.rmc.de
-!- FM 2.02 / ScanToss
! Origin: Don't follow leaders! (2:2480/13.75)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 429 Date: 12 Mar 96 22:41:00
From: William Lipp Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Sloppy Batch
──────────────────────────────────────────────────────────────────────────────
-=> Quoting Larry Nelson to William Lipp <=-
LN> for %%q in (1 2 3) do if errorlevel %%q goto %%q
LN> When I reversed the order of the options in For's set to
LN> (3 2 1) the result was always 1
LN> Any body got an idea why For needs the options in asending
LN> order rather than desending?
The behavior of for-in-do with goto was a topic of discussion a few
months back. My recollection is that the loop finishes all iterations
before executing any "goto" statement. It then acts upon the
last goto.
___ Blue Wave/QWK v2.12
-!- Maximus 3.01
! Origin: this space available bbs (1:141/1111)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 424 Date: 13 Mar 96 20:48:00
From: Vernon Frazee Read: Yes Replied: No
To: Dennis Mccunney Mark:
Subj: Batch Problem
──────────────────────────────────────────────────────────────────────────────
DM> Are you telling 4DOS to load itself and its environment and aliases
DM> into UMBs? There are an assorment of directives settable in
DM> 4DOS.INI to specify this:
DM> UMBAlias Load global aliases in UMB
DM> UMBDirHistory Load global directory history in UMB
DM> UMBEnvironment Load master environment in UMB
DM> UMBHistory Load history in UMB
DM> UMBLoad Load resident part of 4DOS in UMB
DM> Do so, and your environment and other things 4DOS uses come out of
DM> conventional memory, as does all but 256 bytes of the resident
DM> portion of 4DOS itself)
DM> I strongly suspect the memory values you posted above would be
DM> rather different if you did this.
As suggested I created a 4DOS.INI file containing the following:
UMBAlias
UMBDirHistory
UMBEnvironment
UMBHistory
UMBLoad
From "mem/c" before creating 4DOS.INI ------------------------------
Free 747,616 (730K) 635,200 (620K)
From "mem/c" after after creating 4DOS.INI -------------------------
Free 747,616 (730K) 635,200 (620K)
What am I doing wrong?
VF> Hmmm... With just a 360K disk, the tools I would probably grab would
VF> be everything I might need to format a hard drive: DEBUG, FDISK, and
VF> FORMAT (68,020 bytes); a few general tools like: CHKDSK, CHOICE,
VF> EDLIN, and FIND (33439 bytes); of course GWBASIC (80,592 bytes); and
VF> then my communications program {COMMO} (29,872 bytes) so I could
VF> logon to any one of a multitude of systems I have access to and
VF> download anything else I might need. <g> On a MS-DOS v6.22 bootable
VF> diskette that should still leave over 10,000 bytes for whatever
VF> else.
DM> You don't compress the executables?
Not usually, no.
DM> You can't do it to COMMAND.COM, but everything else will pack down
DM> nicely.
DEBUG.EXE, FORMAT.COM, and CHKDSK.EXE already come compressed
but yes, packing the others (PKLITE) reduced overall size by
almost 11%. Good idea, thanks!
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 440 Date: 13 Mar 96 20:48:12
From: Vernon Frazee Read: Yes Replied: No
To: Phi Nguyen Mark:
Subj: write to start of text fi
──────────────────────────────────────────────────────────────────────────────
PN> ---------PREPEND.BTM------------------
PN> @*echo off
PN> *if %# lt 2 goto Syntax_Error
PN> *setdos /x-1
Vf> [ ... 46 lines deleted ... ]
PN> ---------------------------------------
Here's a simple example that works with DOS:
@echo off
:PREPEND.BAT
if (%2)==() goto End
if not exist %1 goto End
set ~fn=%1
copy %~fn% ~1>nul
:Loop
shift
if (%1)==() goto Copy
if not (%~tx%)==() set ~tx=%~tx% %1
if (%~tx%)==() set ~tx=%1
goto Loop
:Copy
echo %~tx%>~2
copy ~2+~1 %~fn%>nul
for %%x in (1 2) do del ~%%x
for %%x in (fn tx) do set ~%%x=
:End
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 15 Mar 96 17:58:01
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Sloppy Batch
──────────────────────────────────────────────────────────────────────────────
JK> for %%a in (1 2 3 4 5 6 7 8 9..... 31) do if errorlevel %%a .....
JK> (A classic .BAT improvement!)
WL> Since the errorlevel function is "errorlevel greater than or equal
WL> to N", this code would execute the "if" section 31 times for a
WL> "no error" return of zero. That was probably not what you had in
WL> mind.
LN> For seems to tweak the order of things. Joe's example worked fine
LN> for me when I use it as in the following....
LN> ::4tst.bat/DOS62.0
LN> @echo off
LN> cls
LN> choice/cabc
LN> for %%q in (1 2 3) do if errorlevel %%q goto %%q
LN> :1
LN> echo a
LN> goto L8r
LN> :2
LN> echo b
LN> goto L8r
LN> :3
LN> echo c
LN> :L8r
LN> When I reversed the order of the options in For's set to (3 2 1) the
LN> result was always "a" Any body got an idea why For needs the options
LN> in asending order rather than desending?
Because DOS will process everything in between the parenthesis
before it makes it's final descision.
For example, with (1 2 3) and you press B, DOS will do:
if errorlevel 1 goto 1 (which proves true)
if errorlevel 2 goto 2 (which proves true)
if errorlevel 3 goto 3 (which proves not true)
Now that it's done testing it does the last thing that proved true,
"goto 2", which is correct.
But if you flip it around, (3 2 1), and press B, DOS will do:
if errorlevel 3 goto 3 (which is not true)
if errorlevel 2 goto 2 (which is true)
if errorlevel 1 goto 1 (which is true)
Now that it's done testing it does the last thing that proved true,
"goto 1", which is incorrect.
Clear as mud yet? <G>
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 16 Mar 96 08:01:00
From: David Roper Read: Yes Replied: No
To: Vernon Frazee Mark:
Subj: BATCH PROBLEM
──────────────────────────────────────────────────────────────────────────────
VF> Hmmm... With just a 360K disk, the tools I would probably grab would
VF> be everything I might need to format a hard drive: DEBUG, FDISK, and
VF> FORMAT (68,020 bytes); a few general tools like: CHKDSK, CHOICE,
VF> EDLIN, and FIND (33439 bytes); of course GWBASIC (80,592 bytes); and
VF> then my communications program {COMMO} (29,872 bytes) so I could
VF> logon to any one of a multitude of systems I have access to and
VF> download anything else I might need. <g> On a MS-DOS v6.22 bootable
VF> diskette that should still leave over 10,000 bytes for whatever
VF> else.
VF> DEBUG.EXE, FORMAT.COM, and CHKDSK.EXE already come compressed
> but yes, packing the others (PKLITE) reduced overall size by
> almost 11%. Good idea, thanks!
Vernon, if you're trying to shrink 'em (and I have a similar disk to
yours for traveling) I used the COMTOEXE and then LZEXE so that I
didn't have to buy PKLITE. Nothing wrong with buying PKLITE, but
for those reading this message, there's the other way "out."
_____oOOo_/00\_oOOo_____ david.roper@mms.raleigh.nc.us
1996 \__/ 201 WINDING BROOK Dr, GARNER NC 27529
-!- FLAME v1.1
! Origin: Full Internet Access $15.00, (919) 779-6674 or MMS.NET (1:151/102)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 17 Mar 96 15:27:05
From: Stamatis Kantartzis Read: Yes Replied: No
To: Jim Danvers Mark:
Subj: Prompt
──────────────────────────────────────────────────────────────────────────────
Hi Jim! What's up?
On 16-Mar-96, at 09:23:00, Jim Danvers wrote this to All about Prompt:
JD> Hi guys... I would like to get a "spinning wheel" type
JD> prompt for command lines. IE;, a spinning | symbol... can we do
JD> this through ansi? That's all.... call me bored. <g>
Here's the latest version of SPIN.BAT:
@echo off
loadbtm on
setlocal
::-----Init spinning characters
set s0=`%=|`
set s1=/
set s2=-
set s3=\
::-----Init pointer to starting position
set s=0
:-----Save cursor
set cursor=%_CO:%_CI
::-----This is for olders version of 4DOS
if "%cursor" eq ":" set cursor=10:100
::-----Turn off cursor
setdos /s0:0
::-----Display title
echo %=nSPIN.BAT - Phi Nguyen 03.04.96%=n
echo Press any key to quit%=n
::-----Display prompt. It requires 2 trailing spaces (1 will be erased)
echos `Please wait: `
do while %_kbhit eq 0
::-----Display spin
:: %=b uses to clear the previous spin char (backspace)
:: %[s%s] uses to show the current spin char (like *ptr in C)
echos %=b%[s%s]
::-----Increase the pointer to next spin char. It will rotate from
:: 0 to 3 to 0 to 3 ...
set s=%@word[%s,1 2 3 0]
::-----Do whatever here
enddo
::-----Clear prompt
echos %=r %=r
::-----Eat keypressed
inkey %%key
::-----Turn on cursor
setdos /s%cursor
endlocal
|-=-=-=> Sincerely, Stamatis Kantartzis <=-=-=-|
.!. Inflation means the Buck does not stop here...
-!- Terminate 3.00
! Origin: (1:109/570.14)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 430 Date: 21 Mar 96 00:16:11
From: Paul Emmons Read: Yes Replied: No
To: Jeff Dubois Mark:
Subj: zipping gazillions of tex
──────────────────────────────────────────────────────────────────────────────
-> Is there a simply way, via batch, to zip up a gazillion *.TXT files
-> into individual zip files and upon completion then delete all the
-> *.TXT files in that directory?
->
-> What I got: A.TXT, B.TXT, C.TXT ...
-> What I want: A.ZIP, B.ZIP, C.ZIP ...
->
-> There is an easy way. But I don't know it. :-)
I think the best way is to create a subdirectory to receive the
zip files, or at least put them in a subdirectory which has no
files *.txt. If this subdirectory is \TEM, then you need:
for %%f in (*.txt) do pkzip -omex \tem\%%f %%f
ren \tem\*.txt *.zip
The pkzip -m flag will remove the files it zips up. The files
created by pkzip in \tem are originally named *.txt, and you
have to rename them *.zip in a separate line.
-!- FidoPCB v1.4 [ff348/b]
! Origin: The Bauding House (1:2626/312) 610/692-7392
─ Area: Batch Language Programming FI ────────────────────
Msg#: 450 Date: 23 Mar 96 23:45:00
From: Gary Smith Read: Yes Replied: No
To: Jeff Dubois Mark:
Subj: zipping gazillions of tex
──────────────────────────────────────────────────────────────────────────────
JD> Is there a simply way, via batch, to zip up a gazillion *.TXT files into
> individual zip files and upon completion then delete all the *.TXT files in
> that directory?
JD> What I got: A.TXT, B.TXT, C.TXT ...
> What I want: A.ZIP, B.ZIP, C.ZIP ...
JD> There is an easy way. But I don't know it. :-)
The following is fairly straightforward. It assumes that you're
running it in the directory where the TXT files reside, and does
no error checking. If you like lots of activity on the screen,
remove the two occurrences of "> nul".
@echo off
md $$temp$$
for %%f in (*.txt) do pkzip -m $$temp$$\%%f %%f > nul
ren $$temp$$\*.txt *.zip
move $$temp$$\*.zip . > nul
rd $$temp$$
-!-
* OLX 1.53 * Veni, vidi, velcro - I came, I saw, I stuck around
-!- WILDMAIL!/WC v4.12
! Origin: The Computer Room-Pickerington, Oh (1:226/110.0)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 26 Mar 96 17:25:02
From: Vernon Frazee Read: Yes Replied: No
To: Roy Reed Mark:
Subj: J. Dubois request, others complaints
──────────────────────────────────────────────────────────────────────────────
RR> I tried a quick and dirty way to convert .txt files to .zip files
RR> per request of Mr. Dubois. Per response of Mr. Primus, this method
RR> did not retain the .txt extension within the zipped file. Per Mr.
RR> Frazee's response, extensionless files in the directory were not
RR> protected. Per this response, the batch file below handles said
RR> complaints. It's just not as cheap and dirty as original. For Mr.
RR> Fraley, I truncated the .txt so that the pkzip command in the
RR> FOR-IN-DO would zip the file and give it the same name, which
RR> resulted in loss of extension inside the .zip file.
RR> I love doing this to get Frazee cranking - hehehehehe.
Guess who? <G>
RR> -!---upper extraction line-----
RR> @echo off
RR> if "%1"=="blasphemy" goto blasphemy
RR> ren *. *.^-^
RR> ren *.txt *.
RR> for %%x in (*.) do call %0 blasphemy %%x
RR> del *.txt
RR> ren *.^-^ *.
RR> set base=
RR> goto end
RR> :blasphemy
RR> set base=%2
RR> ren %2 %2.txt
RR> pkzip %2 %2.txt
RR> :end
RR> -!---lower extraction line-----
Here, try this ZIP&DEL.BAT
@echo off
>~tmptmp~.bat mode %1
>invalid.bat echo set ~fn~=%%3
for %%x in (call del) do %%x ~tmptmp~.bat
pkzip -exmo %~fn~% %1 | del invalid.bat
To use it, first make sure you the above ZIP&DEL.BAT, DOS's MODE.COM
and Phil Katz' PKZIP.EXE in your PATH (or current directory) and at
least 18 bytes free environment space.
Now go to some directory containing at least a few files with the
same extension, for example ".TXT", and then type the command:
for %x in (*.txt) do call zip&del %x
That's it. When this four-working-line "ZIP&DEL.BAT" gets done:
a) all the *.TXT files will each be in their own individual
"samename.ZIP" file
b) with a date and time stamp matching the original file
c) and the originals deleted.
"Kewl" eh? <G>
Now give me something to "crank" on. That may have taken the better
part of maybe a minute to whip up using nothing more than "COPY CON"
a-n-d it required no further editing. <grin>
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate = Pointmailer+Tosser+Reader+Packer+QWK! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 449 Date: 27 Mar 96 03:05:37
From: Dennis Mccunney Read: Yes Replied: No
To: Otto Lang Mark:
Subj: PATH limit
──────────────────────────────────────────────────────────────────────────────
** From Otto Lang to Dennis McCunney on 24 Mar 96 16:30:00
** Re: PATH limit
DM> JC> Well, some of us STILL use only DOS. Like me. I use a menu program,
DM> JC> but I also do things from the DOS prompt and from a File Manager
DM> JC> program. Therefore, I have a fairly long path. Witness:
DM> JC> Path C:\;C:\DOS;C:\UTIL\TV;C:\UTIL\PAK;C:\3DMENU;C:\WP60;
DM> JC> Path %PATH%;C:\UTIL\PGP;C:\UTIL\UUCODE;C:\SOUND\UTIL\DAPLAY;
DM> I still use only DOS here, as well, but I'm at pains to keep my PATH
DM> short. The current one is:
DM> PATH=e:\;c:\usr\batch;c:\usr\vdisk;c:\usr\bin;c:\4dos;c:\usr\lbin;c:\dos;
DM> c:\bin;c:\dgn;..;.
OL> There are two lesson I learned early: (1) Keep dir names short, e.g.
OL> UT or UTL instead of UTIL and (2) if you SUBST U: C:\USR you can save
OL> a lot of typing and see more of your path line in the autoexec.bat.
OL> Just don't forget the LASTDRIVE=Z!
The directory names and directory structure I use are based on those
used by UNIX. I learned UNIX before I really spent any time in DOS,
and I find it simpler to make my DOS environment resemble the one I
have under UNIX as much as possible. (With the MKS Toolkit installed,
that can be more than you would believe...) I've never found SUBST
neccessary, and I use LASTDRIVE=E:, since that IS my last drive.
Seeing the long PATH isn't a big problem, since it isn't that long,
and I'm more concerned about the number of directories in it than the
length of the directory names. Directories are in the PATH in the
order of frequency of access. I keep the command processor and some
frequently used utilities on the ramdisk, so that is first in the PATH.
Saving typing is provided by other 4DOS features. I set
environment variables to the names of frequently used directories.
For example, I have UB=c:\usr\bin in my environment definitions. 4DOS
interprets variables on the command line as well as in batch files, so
I can do "p %ub", instead of "pushd c:\usr\bin". P is an alais for
PUSHD, an internal command in 4DOS that pushes the current directory
onto a stack and changes to the drive directory specified as the
argument. POPD (aliased to "." here) pops the saved drive/directory
from the stack and returns me to where I was.
-!- Blue Wave/DOS v2.30
! Origin: * BlueDog BBS * (212) 594-4425 * NYC FileBone Hub (1:278/304)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 27 Mar 96 16:30:48
From: Vernon Frazee Read: Yes Replied: No
To: Roy Reed Mark:
Subj: IS THIS DIRECTORY EMPTY?
──────────────────────────────────────────────────────────────────────────────
RR> I use dos 5 and the following works for me. I use find to pick out
RR> the "2 files and 0 bytes" if a dir is empty. If not, it doesn't
RR> pick out, and a zero length byte file doesn't get copied, which I
RR> check to see if it exists. I heard 4dos copies 0 byte files. Ta
RR> ta.
RR> -!--- snip line-----
RR> @echo off
RR> if "%1"=="/?" goto syntax
RR> dir %1 | find "2 file(s) 0 bytes" > ~~~4now
RR> copy ~~~4now ~~~after > nul
RR> if exist ~~~after echo directory %1 is empty
RR> if not exist ~~~after echo directory %1 contains at least one file
RR> if exist ~~~4now del ~~~4now > nul
RR> if exist ~~~after del ~~~after > nul
RR> goto end
RR> :syntax
RR> echo proper syntax is, for example, isempty c:\utils or
RR> echo isempty c:\write\wp
RR> :end
RR> -!--- snip line-----
You don't really need to use FIND and a temporary file to do the
trick. For example:
@echo off
:CHKDIR - Does it exist? If so, any files?
if (%1)==() echo Syntax: %0 [[d:]\]dirname[\dir[\dir\...]]
if (%1)==() goto End
if not exist %1\nul echo Directory "%1" does not exist.
if not exist %1\nul goto End
if not exist %1\*.* echo Directory "%1" is empty.
if exist %1\*.* echo Directory "%1" has files.
:End
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Get real, get better, get faster, get Terminate! (1:135/71.16)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 27 Mar 96 09:33:30
From: Vernon Frazee Read: Yes Replied: No
To: Tony Johnston Mark:
Subj: unzip files
──────────────────────────────────────────────────────────────────────────────
TJ> Is it possible to have abat or exe file automatically execute just
TJ> after is has been unzipped. If so how?
With a ZIP file, fortunately no. (Makes it to easy for kids to
automatically launch something destructive). Of course there is
nothing stopping you from simply wrapping a BATch file around it:
@echo off
:START.BAT
md c:\whatever
pkunzip whatever.zip c:\whatever
for %%x in (c: cd\whatever whatever cd\) do %%x
:End
Another alternative is to use ARJ instead of PKZIP. For example,
the following single ARJ command will unarchive FOOBAR.BAT from
archive FOOBAR.ARJ and then immediately launch the FOOBAR.BAT:
arj b foobar.arj foobar.bat -jqfoobar.bat
--- - ---------- ---------- ----------
| | | | |
| | | | |
| | | | `-- DOS command to execute after
| | | | the extraction has occurred
| | | |
| | | `-- Name of the file to extract
| | |
| | `-- Name of the ARJ archive to use
| |
| `-- Allow user to execute a DOS command
| on selected file(s) in the archive
|
`-- Launch ARJ.EXE
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate SmartNote: Remembers & recalls everything! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 442 Date: 28 Mar 96 07:31:30
From: Vernon Frazee Read: Yes Replied: No
To: Otto Lang Mark:
Subj: debug or share
──────────────────────────────────────────────────────────────────────────────
OL> ... PPT insists on having SHARE.EXE loaded. I guess because of
OL> Windows' multitasking? Anyway, as soon as I added
OL> INSTALL=C:\DOS\SHARE.EXE to my CONFIG.SYS the next boot hung on
OL> errors in the debug statement in CURRENT.[BAT]. ... Debug ... errors
OL> ... trying to load from ... <temptemp.scr.
OL> :CURRENT.BAT from Fidonet ... BATPOWER. ... Vernon Frazee 01/17/94
I'm getting the same results here -- under DOS v6.22. How about a
newer version, GET-DT.BAT (Get Date and Time), that will not only
work with SHARE loaded, (and/or should run fine under Windows95),
but also sets Day in evar "DY", Month in evar "MM", Day date in evar
"DD", Year in evar "YY", Hour in evar "HR", Minute in evar "MN", and
Second in evar "SC"?
:GET-DT.BAT - Type "GET-DT /?" (not the quotes) for help
:Note: Do NOT put a "@echo off" at the beginning of this file!
:Begin -------------------------------------------------------
@if (%1)==(/?) goto Syntax
@if (%1)==(!!) goto GetMDY
@if (%1)==(!) prompt set dt=!! $d $t
@if (%1)==(!) goto End
@echo off
for %%x in (dt dy mm dd yy hr mn sc) do set %%x=
command /c %0 !>~tmp_01~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
%0 %dt%
:GetMDY ------------------------------------------------------
set dt=
set DY=%2
shift|shift
echo;;|choice /c:;%1%; "~tmp_02~ ">~tmp_01~.bat
echo set mm=%%2%%3>>~tmp_02~.bat
echo set dd=%%5%%6>>~tmp_02~.bat
for %%x in (1 2) do echo shift>>~tmp_02~.bat
echo set yy=%%8%%9>>~tmp_02~.bat
call ~tmp_01~.bat
:GetHMS ------------------------------------------------------
echo;;|choice /c:;%2%; "~tmp_02~ ">~tmp_01~.bat
echo if (%%3)==(:) goto Insert0>~tmp_02~.bat
echo set hr=%%2%%3>>~tmp_02~.bat
echo set mn=%%5%%6>>~tmp_02~.bat
echo set sc=%%8%%9>>~tmp_02~.bat
echo goto End>>~tmp_02~.bat
echo :Insert0>>~tmp_02~.bat
echo set hr=0%%2>>~tmp_02~.bat
echo set mn=%%4%%5>>~tmp_02~.bat
echo set sc=%%7%%8>>~tmp_02~.bat
echo :End>>~tmp_02~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
del ~tmp_02~.bat
:************************************************************:
: To display results, change the next line to "goto Display" :
:************************************************************:
goto End
:Syntax ------------------------------------------------------
@echo off
cls
echo Name: GET-DT.BAT - Get current system Date and Time
echo.
echo Author: Vernon Frazee 06/14/94 - (Last mod: 03/28/96)
echo.
echo Purpose: Store the current system:
echo.
echo Day in evar "DY" (example: DY=Tue)
echo Month in evar "MM" (example: MM=05 )
echo Day date in evar "DD" (example: DD=31 )
echo Year in evar "YY" (example: YY=94 )
echo Hour in evar "HR" (example: HR=06 )
echo Minute in evar "MN" (example: MN=22 )
echo Second in evar "SC" (example: SC=00 )
echo.
echo Syntax: [call] [d:[\path]]GET-DT [/?]
echo.
echo Where: /? displays this help screen
echo.
echo Requires: DOS's COMMAND.COM and CHOICE.COM (somewhere in
echo the PATH is fine), and 43 bytes of free space
echo in the environment.
echo.
echo Note: "evar" is short for "environment variable".
echo.
goto End
:Display -----------------------------------------------------
echo DY=%dy% MM=%mm% DD=%dd% YY=%yy% HR=%hr% MN=%mn% SC=%sc%
:End --------------------------------------------------- -vjf-
(Note: I would normally test this under Windows95 first for you,
but, at the moment I'm at the beach waiting for breakfast to arrive
and tapping away on this DOSv6.22/WFWGv3.11 based Laptop. <g>)
./~ She wore an itsy bitsy teeny weeny yellow polka-dot bikini.. ./~
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: The NEW Terminate will -=> FAX <=- almost anything! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 28 Mar 96 06:07:54
From: Vernon Frazee Read: Yes Replied: No
To: Josef Schwartz Mark:
Subj: how do I...
──────────────────────────────────────────────────────────────────────────────
VF> The following ANSI escape sequence sets the [UpArrow] so it acts
VF> like a press of the [Enter] key: <-[0;72;"";13p
> [snip]
JS> What would I have to do to switch the ";" with the ":" ?
I used to do that too, years ago, and still have customers
occasionally requesting the same. All it really takes is a couple
of escape sequences, (much like the one above), but, instead of
trying to explain how to do ANSI escape sequences, I've simply been
giving them the enclosed SEMISWAP.BAT along with the following
SEMISWAP.BAT Instructions:
1) Place a copy of the enclosed SEMISWAP.BAT in a directory in your
PATH. (For example, in "C:\BAT").
2) Make sure your CONFIG.SYS file has something similar to the
following line in it: DEVICE=C:\DOS\ANSI.SYS
3) Insert the following line near the beginning of your AUTOEXEC.BAT
file: CALL C:\BAT\SEMISWAP.BAT /ON
4) Reboot and get to the DOS prompt.
5) Type "SEMISWAP" (not the quotes) and the current status should be
"SEMISWAP=On". If it is, your ";" and ":" keys should now be
swapped. If not, start back at "1)", making sure sure each and
every character is correct and that the "drive:\path\" on each
line actually points to the respective file. (In other words,
does the ANSI.SYS file actually exist in directory C:\DOS?; etc.)
------------------------------> Cut Here <------------------------------
@echo off
:SEMISWAP.BAT - Swaps the ":" and ";" keys, or resets to normal.
goto ParmCheck
:Syntax ----------------------------------------------------------------
cls
echo Name: SEMISWAP.BAT (Vernon Frazee 03/11/84, Last Mod 03/28/96)
echo.
echo Purpose: Swaps the semi-colon ";" and the colon ":" keys.
echo.
echo "/On" = Swapped and "/Off" = Normal
echo.
echo In other words, when On or swapped:
echo.
echo a) simply pressing the [;] key will now produce the ":"
echo character (instead of having to hold down the [Shift]
echo key and pressing the [;] key to get it).
echo.
echo b) and to get the ";" character, you will now have to
echo hold down the [Shift] key and press [;].
echo.
echo Syntax: [call] [d:][\path]SEMISWAP [/On (or) /Off (or) /?]
echo.
echo SEMISWAP - Display current status
echo SEMISWAP /On - Swap ":" with ";"
echo SEMISWAP /Off - Return ":" and ";" to normal
echo SEMISWAP /? - Display this screen
echo.
echo Requires: DOS' ANSI.SYS (or equivalent) and up to 13 bytes of free
echo environment space. (Evar SEMISWAP=On or SEMISWAP=Off).
goto End
:ParmCheck -------------------------------------------------------------
if (%1)==() goto Display
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
for %%x in (on On ON oN) do if (%1)==(/%%x) goto On
for %%x in (off Off OFf OFF oFF ofF) do if (%1)==(/%%x) goto Off
goto Syntax
:Display status --------------------------------------------------------
if (%SEMISWAP%)==() set SEMISWAP=Off
echo SEMISWAP=%semiswap%
goto End
:On (Swap the ";" and ":" keys) ----------------------------------------
echo [58;59p [59;58p [1A
rem `-------`-------`------- Three [Esc] characters (Alt-27's)
set SEMISWAP=On
goto Display
:Off (Unswap the ";" and ":" keys (back to normal)) --------------------
echo [58;58p [59;59p [1A
rem `-------`-------`------- Three [Esc] characters (Alt-27's)
set SEMISWAP=Off
goto Display
:End ------------------------------------------------------------- -vjf-
------------------------------> Cut Here <------------------------------
6) To view SEMISWAP's brief instructions type: SEMISWAP /?
That's it. Enjoy!
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: The NEW Terminate will -=> FAX <=- almost anything! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 431 Rec'd Date: 01 Apr 96 08:24:39
From: Vernon Frazee Read: Yes Replied: No
To: Bat Lang Mark:
Subj: Echoing redirection chara
──────────────────────────────────────────────────────────────────────────────
VF> Change to the directory containing your SCRipt files and create
VF> the following 1-line "X.BAT":
VF> @debug<%1
VF> Now type the command:
VF> for %x in (*.scr) do call x %x
VF> and all the SCRipt files in the current directory will be
VF> processed by DEBUG.
BL> Vernon, would appreciate a short {^; synopsis that would teach us
BL> all, the set of circumstances that lead to deciding: when it's
BL> better/best to use the FOR...IN...DO from the command line, rather
BL> than including it within a batch file.
BL> I'm sure we will all be grateful for this poop! Thanks, and Good
BL> Modeming! /\oo/\
Hmmm... If it's something that will be used repetitively, I
usually wrap a BATch file around it. For instance, the above
might be _quickly_ thrown together as:
@echo off
:DEBUG'EM.BAT
if (%2)==(~!~) goto DoIt
for %%x in (*.scr) do call %0 %%x ~!~
:DoIt
if (%1)==() goto End
echo %1
debug<%1>nul
:End
The short solution I gave above must have been because it appeared
that the user posing the question needed to do the task but once.
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Have you ever been TERMINATEd ? (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 425 Date: 01 Apr 96 16:51:00
From: TYRIN PRICE Read: Yes Replied: No
To: INGRID DEKKER Mark:
Subj: CHOICE
──────────────────────────────────────────────────────────────────────────────
Hi Ingrid!
ID>Can someone tell me how to use the CHOICE command for more than two options
ID>list the options right behind the number (ie: 1 start anyprogram) without
ID>getting the [Y/N] returned from DOS? Or is it enought to just echo the opti
ID>and set errorlevels without CHOICE?
CHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] [text]
/C[:]choices Specifies allowable keys. Default is YN
/N Do not display choices and ? at end of prompt string.
/S Treat choice keys as case sensitive.
/T[:]c,nn Default choice to c after nn seconds
text Prompt string to display
ERRORLEVEL is set to offset of key user presses in choices.
You could TYPE a text file to the screen or ECHO a menu to the screen
like this...
ECHO 1) Word Processor
ECHO 2) Database
ECHO 3) Spreadsheet
ECHO 4) Telecommunications
And then use CHOICE like this
CHOICE /C1234 /N What'll It Be?
IF ERRORLEVEL 4 TELIX
IF ERRORLEVEL 3 LOTUS
IF ERRORLEVEL 2 DBASE
IF ERRORLEVEL 1 WP
-=Ty=-
* SLMR 2.1a * BREKFAST.COM halted: cereal port not found.
-!- GOMail v2.0 [94-0021]
! Origin: The Home of Aunt Gabby (1:123/17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 444 Date: 01 Apr 96 16:33:00
From: Roy Reed Read: Yes Replied: No
To: Robert Morton Mark:
Subj: Unique filenames
──────────────────────────────────────────────────────────────────────────────
I took a beautiful batch file by Vernon Frazee and butchered it to
get into envars the last digit of the year, one hex letter/number for
the month, two digits for the day, and the total seconds from the
current hour, minute and seconds plus offsetting it in an envar called
addxx. I didn't go to the extent of saving the filename-base in an
envar from %1 for you. Type set to see all. I now know three tips
of Frazee's seven million. Used them here. Never catch that hummer.
Just run it to see the stuff in the environment. You'll need
CHANGE.COM,
CHOICE, GWBASIC, and CHANGE.COM.
---------------- snip ------------------
:MORTON.BAT - Type "MORTON /?" (not the quotes) for help
:Note: Do NOT put a "@echo off" at the beginning of this file!
:Begin -------------------------------------------------------
@if (%1)==(/?) goto Syntax
@if (%1)==(!!) goto GetMDY
@if (%1)==(!) prompt set dt=!! $d $t
@if (%1)==(!) goto plum
@echo off
for %%x in (dt dy mm dd yy hr mn sc) do set %%x=
command /c %0 !>~tmp_01~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
%0 %dt%
:GetMDY ------------------------------------------------------
set dt=
set DY=%2
shift|shift
echo;;|choice /c:;%1%; "~tmp_02~ ">~tmp_01~.bat
echo set mm=%%2%%3>>~tmp_02~.bat
echo set dd=%%5%%6>>~tmp_02~.bat
for %%x in (1 2) do echo shift>>~tmp_02~.bat
echo set yy=%%9>>~tmp_02~.bat
call ~tmp_01~.bat
:GetHMS ------------------------------------------------------
echo;;|choice /c:;%2%; "~tmp_02~ ">~tmp_01~.bat
echo if (%%3)==(:) goto Insert0>~tmp_02~.bat
echo set hr=%%2%%3>>~tmp_02~.bat
echo set mn=%%5%%6>>~tmp_02~.bat
echo set sc=%%8%%9>>~tmp_02~.bat
echo goto End>>~tmp_02~.bat
echo :Insert0>>~tmp_02~.bat
echo set hr=0%%2>>~tmp_02~.bat
echo set mn=%%4%%5>>~tmp_02~.bat
echo set sc=%%7%%8>>~tmp_02~.bat
echo :End>>~tmp_02~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
del ~tmp_02~.bat
:************************************************************:
: To display results, change the next line to "goto Display" :
:************************************************************:
goto End
:Syntax ------------------------------------------------------
@echo off
echo Requires: DOS's COMMAND.COM, CHOICE.COM & CHANGE.COM
echo & GWBASIC (somewhere in the PATH is fine)
echo.
goto plum
:Display -----------------------------------------------------
echo MM=%mm%=month in hex SS=%ss%=total seconds in time
echo (hour,min,sec) YY=%yy%=1 digit for year
:End --------------------------------------------------- -vjf-
echo ? (%hr%*3600)+(%mn%*60)+(%sc%):system|gwbasic > ~~temp~~.bat
echo h$=hex$(%mm%):? h$:system|gwbasic >> ~~temp~~.bat
call change.com ~~temp~~.bat 13,10 32
for %%x in (dy hr mn sc) do set %%x=
call change.com ~~temp~~.bat 79,107,255 "~~^~~"
echo set ss=%%3>~~^~~.bat
echo set mm=%%8>>~~^~~.bat
call ~~temp~~
del ~~temp~~.bat
del ~~^~~.bat
set ymds=%YY%%MM%%DD%%SS%
echo;;|choice /c:;%ymds%; "~~~~~ ">~~~~.bat
call change ~~~~.bat 91,59,44 ""
echo set addxx=%%1%%2%%3%%4%%5%%6%%7%%8.%%9>~~~~~.bat
call ~~~~.bat
for %%y in (~~~~~ ~~~~) do del %%y.bat
:plum
---------------- snip ------------------
You'll have to null out the envars later yourself.
L8tr.
! Origin: The Bargain Trader BBS *Tampa,FL* (813)249-8595 (1:377/68)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 28 Mar 96 21:25:29
From: Tony Baechler Read: Yes Replied: No
To: Jeff Dubois Mark:
Subj: zipping gazillions of text files
──────────────────────────────────────────────────────────────────────────────
|Quoting Jeff to All on 18 Mar 96 23:55:18.|
JD> Is there a simply way, via batch, to zip up a gazillion *.TXT files
JD> into individual zip files and upon completion then delete all the
JD> *.TXT files in that directory?
I recently discovered a util by Horst in HORST_2.ZIP called LISTMOD.
COM which sounds like it might work. You will have to play around
with this a little, but I think something like this might work.
@ECHO OFF
DIR /B|LISTMOD /S. PKZIP $01 $01.$02 >OUT.BAT
CALL OUT.BAT
I am sure the following is not quite right, so experimentation is in
order here. HORST_2 was sent into BFDS.
Mail: 1:202/1333 or baechler@crl.com, ftp://ftp.crl.com/users/ba/baechler
... Is that your Tagline or did your mail reader throw up?
-!- Blue Wave/DOS v2.30
! Origin: Total Control BBS (ltd. hours) (1:202/1333)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 03 Apr 96 09:12:23
From: Vernon Frazee Read: Yes Replied: No
To: Bob Morton Mark:
Subj: JULIAN DATE 2 ENV
──────────────────────────────────────────────────────────────────────────────
BM> Does anyone have a batch segment that will read today's date and
BM> convert it to Julian format?
BM> Actually, I need to build up a filename that is guaranteed to be
BM> unique every time it is created. I need to use two characters out
BM> of the 8.3 format for another purpose, so I have 8.1 left for use.
BM> I was thinking of YJJJHHMM.SSXX where XX are the two characters I
BM> need to use, but as you can see, that's still one character too
BM> long. How about converting HHMMSS into relative seconds--a number
BM> from 1 to 86400? Hmmmmm..that would do it: changes 6 characters
BM> (HHMMSS) into 5 digits--YJJJSSSS.SXX
BM> Guess I'd better not do this arithmetic in batch unless one of the
BM> frequently mentioned utilities will do it.
How about doing it like this:
The 1st digit of the filename. Like you said, use 1 digit for the
year -- the last digit. For example, this is 1996 so it would be a
"6". (Of course this means that a decade from now a filename could
get overwritten <g>. I'll come back to this in a sec.).
The 2nd digit of the filename. Use 1 digit for the month -- "1"
thru "9" for Jan thru Sep, and then an "A", "B", and "C", for Oct,
Nov, and Dec respectively.
The 3rd digit of the filename. Use 1 digit for the day -- "1" thru
"9" for the 1st thru the 9th, and then an "A" for the 10th, "B" for
the 11th, "C" for the 12th etc. on up thru a "U" for the 31st day of
the month.
So far then, out of your "8.1" or "9 total digit" specification, we
have only used up three digits that cover the Year, Month, and Day.
That means we still have 6 digits for the hours, minutes, and
seconds. And, since the hours minutes and seconds are always no
more than two digits each, we can now simply use them without having
to convert a thing.
For example, right now it is | And for an example shows what
04/03/96 09:39:09 which means | happens when the month and day
the filename would be: | get up into the alphabetical
| chars., on 12/31/96 at 23:59:45
| the filename would be:
|
64309390.9 | 6CU23594.5
|||||||| | | |||||||| |
|||||||` `- Seconds | |||||||` `- Seconds
|||||``---- Minutes | |||||``---- Minutes
|||``------ Hours | |||``------ Hours
||`-------- Day | ||`-------- Day
|`--------- Month | |`--------- Month
`---------- Year | `---------- Year
(BTW, since "A", "B", "C" etc. come after "1", "2", "3" etc. when
sorted alphabetically, a sorted DIRectory listing will have the
filenames in sorted by date/time order).
Now back to the 10 year thing. In exactly 10 years from say
"12/31/96 at 23:59:45" it would be
"12/31/06 at 23:59:45" which, as you can see means that using
this approach will result with two identical filenames. This
probably won't be a problem however since most won't keep data
files for a decade. But, if so, one could simply create another
subdirectory to keep them in. Say for instance: C:\1990'S,
C:\2000'S, C:\2010'S etc. or C:\1996, C:\1997, . . . whatever).
If this approach sounds workable, here's a BATch file that uses
QBASIC to create the 8.1 portion of your filename and then sticks it
in an environment variable for you -- (so you can then tack on
whatever last two digits you want with your BATch file).
@echo off
:-----------------------------------------------------------------
:G9DFN.BAT - Generates a unique 9-Digit left justified 8.1 format
: FileName based on current system date & time.
: Requires: QBASIC (in PATH) and 16 bytes free environment space.
:-----------------------------------------------------------------
set G9DFN=
echo DIM wn(30):FOR x=1 TO 30:READ wn(x):NEXT x>~tmp~.bas
echo DATA 49,50,51,52,53,54,55,56,57,65,66,67,68,69,70>>~tmp~.bas
echo DATA 71,72,73,74,75,76,77,78,79,80,81,82,83,84,85>>~tmp~.bas
echo yy=VAL(MID$(DATE$,10,1)):mm=VAL(MID$(DATE$,1,2))>>~tmp~.bas
echo dd=VAL(MID$(DATE$,4,2)):hr$=MID$(TIME$,1,2)>>~tmp~.bas
echo mn$=MID$(TIME$,4,2):sc1$=MID$(TIME$,7,1)>>~tmp~.bas
echo sc2$=MID$(TIME$,8,1)>>~tmp~.bas
echo OPEN "~tmp~.bat" FOR OUTPUT AS #1>>~tmp~.bas
echo PRINT #1,"set G9DFN=";CHR$(wn(yy));CHR$(wn(mm));>>~tmp~.bas
echo PRINT #1,CHR$(wn(dd));hr$;mn$;sc1$;".";sc2$>>~tmp~.bas
echo CLOSE:SYSTEM>>~tmp~.bas
qbasic /run ~tmp~.bas
del ~tmp~.bas
for %%x in (call del) do %%x ~tmp~.bat
echo G9DFN=%G9DFN%
:End ------------------------------------------------------- -vjf-
-- NetMail: 1:135/71 E-Mail: vernon.frazee@71.sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate is now specially built for Internet! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 04 Apr 96 11:26:51
From: Vernon Frazee Read: Yes Replied: No
To: Jeff Cole Mark:
Subj: Need help with a BAT program
──────────────────────────────────────────────────────────────────────────────
JC> I regularly decode UUENCODED graphics files from an fidoecho. After
JC> saving the UUCODE posts, I drop to DOS decode the file, and then run
JC> my graphics program to see what it looks like. My question is, how
JC> can I call my graphics program and then return to the directory I
JC> called it from? My guess is something like this:
JC> cd < curdir
JC> cd c:\graphics\gds
JC> gds.exe
JC> cd %curdir%
JC> Would that work?
Unfortunately no, but, it really isn't much more complicated than
that. Here, try it like this:
@echo off
:GDS.BAT - Loads GDS and returns to current dir
:Save current drive:\dir -----------------------
echo @prompt cd $p$_$n:>%temp%\~tmp~.bat
%comspec% /c %temp%\~tmp~.bat>%temp%\return.bat
del %temp%\~tmp~.bat
:Load GDS --------------------------------------
for %%x in (c: cd\graphics\gds) do %%x
gds.exe %1 %2 %3 %4 %5 %67 %7 %8 %9
:Return to saved drive:\dir --------------------
for %%x in (call del) do %%x %temp%\return.bat
:End -------------------------------------------
Note: The five lines beginning with ":" can be removed if you like.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate is now specially built for Internet! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 422 Date: 04 Apr 96 22:37:05
From: James Hill Read: Yes Replied: No
To: MIKE DUTTERA Mark:
Subj: Get date?
──────────────────────────────────────────────────────────────────────────────
In a msg on <Mar 05 09:45>, MIKE DUTTERA of 1:270/616 writes:
SH>>What I'd like to do is have a plain vanilla batch file that
SH>>grabs the day of the month so that on the 3rd, for example, I
SH>>could defrag my HD, on the 4th run scandisk, etc. etc.
SH>>I figure it would have to be something that grabs the day of
SH>>the month as an env variable then the calling batch files
SH>>would check this to see if its the right day.
MD> Piece 'o cake. Just use MS-DOS's DATE and FIND functions in a
MD> batch using the general form:
MD> DATE|FIND "-03-"
MD> IF ERRORLEVEL 0 IF NOT ERRORLEVEL 1 GOTO BLAHBLAH
or you could have done;
echo.|date|find "-03-"|if not errorlevel 1 defrag c: /f /h /sn
echo.|date|find "-04-"|if not errorlevel 1 scandisk c: /autofix
enjoy.
-!- msgedsq 2.1
! Origin: Selective On-Line (tm) - Santa Fe, NM - (505) 473-9765 - (1:15/11)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 424 Date: 25 Mar 96 19:04:40
From: Michael Marquart Read: Yes Replied: No
To: Paul Laufer Mark:
Subj: Strip .EXT from command line
──────────────────────────────────────────────────────────────────────────────
~~ Paul Laufer said to All ~~
~~ Regarding Strip .EXT from command line ~~
~~ on 17 Mar 96 22:27:58 ~~
Hi Paul!
PL> TESTBAT.BAT C:\PATH\FILE.EXT
PL> ...I would like this batch file to know that this is an (EXT) file
PL> and "GOTO EXT". Then I could process the file as a .EXT file.
PL> If it's a .ZIP file it would "GOTO ZIP" in the batch process and
PL> I could process it as a .ZIP file.
Try this: tested on MSDOS V6.22 and uses only command.com.
:: Call_me_what_you_will.bat ===========================================
@echo off
set exten=%1
:nextchar
set prev=%exten%
for %%f in (/%exten%) do set exten=%%f
if ".%exten%"=="%prev%" goto extfound
if not "%exten%"=="%prev%" goto nextchar
echo There was no extension given on the command line for the filename!
goto end
:extfound
echo Extension is %prev%
for %%f in (/%prev%) do set ext=%%f
echo going to label %ext%
goto %ext%
:bat
echo :bat
goto end
:com
echo :com
goto end
:exe
echo :exe
goto end
:txt
echo :txt
goto end
:end
for %%f in (ext prev exten) do set %%f=
::======================================================================
The method was ripped off err... borrowed from one of the good denizens of
this echo!
Regards
Mic
... Clowns to the left of me, jokers to the right...
-!-
! Origin: Melbourne PC User Group +61-3-9699-6788 (3:632/309)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 07 Apr 96 06:43:35
From: Vernon Frazee Read: Yes Replied: No
To: Osgar Schaedtler Mark:
Subj: FIND, DELETE and FC
──────────────────────────────────────────────────────────────────────────────
OS> I've made a file, named FILE1.TXT, made with the command:
OS> DIR /B /A-D >FILE1.TXT
OS> Now I want to make a program that will do the following thing:
OS> The files in that directory have to be compared with the file
OS> FILE1.TXT. If there are some different files between the files in
OS> the directory and the files in FILE1.TXT, then I want to delete
OS> these files out of the directory. Has somebody an idea? I've
OS> tried something with the commands FIND and FC, but that didn't
OS> work. So, help me please!
There is an easier way. All it takes is one "for in do" command.
Let's say you have two directories. One named MASTER containing the
files you want to compare to, and another named FOOBAR that contains
a few files that are named the same as well as some extra junk files
that you want to get rid of. For example:
=================================+==================================
Directory of C:\MASTER | Directory of C:\FOOBAR
|
1 TXT 0 04-07-96 6:45a| 1 TXT 0 04-07-96 6:45a
2 TXT 0 04-07-96 6:45a| 2 TXT 0 04-07-96 6:45a
3 TXT 0 04-07-96 6:45a| 3 TXT 0 04-07-96 6:45a
| 4 TXT 0 04-07-96 6:45a
| 5 TXT 0 04-07-96 6:45a
=================================+==================================
(IOW, we want to get rid of "4.TXT" and "5.TXT" in C:\FOOBAR).
All it takes to do this is one DEL command.
First change to the directory that contains the files you want to
get rid of -- which in our example here is C:\FOOBAR. Now type the
following command at the DOS prompt:
--> for %x in (*.*) do if not exist c:\master\%x del %x
And that's it, you'll now have:
=================================+==================================
Directory of C:\MASTER | Directory of C:\FOOBAR
|
1 TXT 0 04-07-96 6:45a| 1 TXT 0 04-07-96 6:45a
2 TXT 0 04-07-96 6:45a| 2 TXT 0 04-07-96 6:45a
3 TXT 0 04-07-96 6:45a| 3 TXT 0 04-07-96 6:45a
=================================+==================================
Pretty "Kewl!" eh? <g>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 3.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 09 Apr 96 22:54:00
From: Benjamin L Mcgee Read: Yes Replied: No
To: All Mark:
Subj: CHEESY WINDOWS ENVIRON
──────────────────────────────────────────────────────────────────────────────
Here's a little somethin' I came up with so I can safely run
Binkley Term under Windows (so I can play Comet Busters while I
download QWK packets). It just prevents me from running Bink
twice which causes all sorts of problems, and it compensates for
the lack of a true environment variable under Windows. An old
trick I'm sure but I thought it might be helpful.
@echo off
cls
if exist c:\binkley\~windows.var goto error
:: set a HARD environment variable
rem > c:\binkley\~windows.var
:dumb
:: truncate log file
rem > c:\binkley\binkley.log
:: load vfos
c:\binkley\vfoss\vfos_ibm
c:
cd \binkley
bt.exe
:: unload vfos
c:\binkley\vfoss\vfos_del
del c:\binkley\~windows.var
goto quit
:error
echo.
echo Binkley Term is already running!
echo Running Bink twice under Windows is NOT good!
choice /cyn Do you wish to run Bink again anyway [Y/N]?
if errorlevel 2 goto quit
if errorlevel 1 goto dumb
:quit
Benjamin L McGee on 1:15/7
*Drop that pickle.
-!- FLAME v1.1
! Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 416 Date: 11 Apr 96 02:47:12
From: Vernon Frazee Read: Yes Replied: Yes
To: All Mark:
Subj: AVGFILES.BAT
──────────────────────────────────────────────────────────────────────────────
Hello all,
I'd sure appreciate if some of you running on MS-DOS 6.nn would run
the following and report back the resultant "average number of files
per directory" on your systems.
@echo off
:AVGFILES.BAT ------------------------------------------------------
goto Begin
:Syntax ------------------------------------------------------------
echo.
echo Name: AVGFILES.BAT v1.00
echo Author: Vernon Frazee 04/09/96
echo Purpose: Calculate the average number of files
echo per directory for the drive specified.
echo Syntax: AVGFILES d:
echo Where: "d:" is the drive to check
echo Requires: DOS' CHKDSK, FIND and QBASIC
echo (anywhere in PATH is fine).
echo Notes: Specified drive must contain at least one
echo directory and one file in the root directory.
echo Hidden files are NOT included.
echo Has only been tested on MS-DOS v6.nn
echo.
goto End
:Begin -------------------------------------------------------------
if (%1)==() goto Syntax
if not exist %1\nul goto DriveErr
if not exist %1\*.* goto FileErr
dir %1|find "DIR"|find " ">~tmp_01~.dat
copy ~tmp_01~.dat+,,>nul
if not exist ~tmp_01~.dat goto DirErr
:Gather data on specified drive ------------------------------------
echo.
echo Counting files and directories on drive "%1" ...
echo.
chkdsk %1|find /v "a"|find "in"|find /v "dd">~tmp_01~.dat
:Display CHKDEK data -----------------------------------------------
echo CHKDSK data for drive "%1"
echo.
type ~tmp_01~.dat
echo.
:Create QBASIC program to do the calculations ----------------------
echo OPEN "~tmp_01~.dat" FOR INPUT AS #1>~tmptmp~.bas
echo OPEN "~tmp_02~.dat" FOR OUTPUT AS #2>>~tmptmp~.bas
echo DO WHILE NOT EOF(1)>>~tmptmp~.bas
echo LINE INPUT #1, Rec$>>~tmptmp~.bas
echo Rec$ = MID$(Rec$, 24, 18)>>~tmptmp~.bas
echo FOR Count = 1 TO 18>>~tmptmp~.bas
echo IF MID$(Rec$, Count, 1) = "," THEN>>~tmptmp~.bas
echo Stn$ = "">>~tmptmp~.bas
echo END IF>>~tmptmp~.bas
echo IF NOT MID$(Rec$, Count, 1) = "," THEN>>~tmptmp~.bas
echo Stn$ = MID$(Rec$, Count, 1)>>~tmptmp~.bas
echo END IF>>~tmptmp~.bas
echo IF UCASE$(Stn$) = LCASE$(Stn$) THEN>>~tmptmp~.bas
echo x$ = x$ + Stn$>>~tmptmp~.bas
echo END IF>>~tmptmp~.bas
echo NEXT Count>>~tmptmp~.bas
echo PRINT #2, x$>>~tmptmp~.bas
echo x$ = "">>~tmptmp~.bas
echo LOOP>>~tmptmp~.bas
echo CLOSE>>~tmptmp~.bas
echo OPEN "~tmp_02~.dat" FOR INPUT AS #1>>~tmptmp~.bas
echo LINE INPUT #1, d$: LINE INPUT #1, f$>>~tmptmp~.bas
echo a = CSNG(VAL(f$) / VAL(d$))>>~tmptmp~.bas
echo a$ = LTRIM$(RTRIM$(STR$(a)))>>~tmptmp~.bas
echo PRINT "Average number of files";>>~tmptmp~.bas
echo PRINT " per directory: "; a$>>~tmptmp~.bas
echo CLOSE : SYSTEM>>~tmptmp~.bas
:Run QBASIC program ------------------------------------------------
qbasic /run ~tmptmp~.bas
echo.
goto Cleanup
:DriveErr ----------------------------------------------------------
echo.
echo Error: Drive "%1" is not a valid drive
goto Syntax
:FileErr -----------------------------------------------------------
echo.
echo Error: Drive "%1" must contain at least
echo one file in the root directory
goto Syntax
:DirErr ------------------------------------------------------------
echo.
echo Error: Drive "%1" must contain at least
echo one subdirectory
goto Syntax
:Cleanup -----------------------------------------------------------
for %%x in (1 2) do del ~tmp_0%%x~.dat
del ~tmptmp~.bas
:End --------------------------------------------------------- -vjf-
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 418 Date: 09 Apr 96 08:23:00
From: Horst Schaeffer Read: Yes Replied: No
To: Scott Sellars Mark:
Subj: Batch File Help...
──────────────────────────────────────────────────────────────────────────────
-=> quoting Scott Sellars to Clay Cherneff (5 Apr 96) <=-
SS> I want to generate errorlevels so i can test out my batch files.
some errorlevel test tools:
-+-+-----
n EL!.COM
e100 BE 81 0 AC "< t"FB "N<0r"1B "+"C0 "*"FF BA A 0 8A 1C "F"80 EB "0"
e11A ":"DA "s"6 F7 E2 1 D8 "s"ED B4 "L"CD "!"BA "3"1 B4 9 CD "!*"C0 EB
e132 F1 "EL! n"D A "sets errorlevel to n=0..255"D A "$"
rCX
58
w
q
-+-+-----
Cut out and save (any filename), then run: DEBUG < filename
-+-+-.... and to display the errorlevel:
@echo off
:: return errorlevel EL & echo
set !=
set EL=
for %%h in (0 1 2) do if errorlevel %%h00 set EL=%%h
if not errorlevel 200 set !=6 7 8 9
for %%t in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%t0 set EL=%EL%%%t
if not errorlevel 250 set !=6 7 8 9
for %%u in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%u set EL=%EL%%%u
echo Errorlevel %EL%
set !=
-+-+-
Horst.
... Q4FM 2.10 ... horst@confusion.rmc.de
-!- FM 2.02 / ScanToss
! Origin: Don't follow leaders! (2:2480/13.75)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 14 Apr 96 20:48:00
From: Benjamin L Mcgee Read: Yes Replied: No
To: Jay Fuller Mark:
Subj: QUESTION CONCERNING "FIND
──────────────────────────────────────────────────────────────────────────────
On 04-09-96 JAY FULLER wrote to ALL...
JF> Greetings everyone,
Hello!
JF> I'm attempting to write a batch file that will do the
JF> following.....
JF> if find log.txt "SUCCESS" goto success
JF> if find log.txt "ILLEGAL" goto illegal
Do you program in 'C' or 'C++'? DOS's IF just ain't that good.
added /i to ignore case
added > nul to hide output of find
find returns errorlevel 2 if an error occured while trying
to read from the file, errorlevel 1 if no error occured but the
search string wasn't found, and errorlevel 0 if no error occured
and the search string was found
find /i "SUCCESS" LOG.TXT > nul
if errorlevel 2 goto error
if not errorlevel 1 goto success
find /i "ILLEGAL" LOG.TXT > nul
if errorlevel 2 goto error
if not errorlevel 1 goto illegal
Benjamin L McGee on 1:15/7
*Don't read everything you believe.
-!- FLAME v1.1
! Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 439 Date: 16 Apr 96 21:16:19
From: Vernon Frazee Read: Yes Replied: No
To: Kenny Eschrich Mark:
Subj: old tandy-autoexec
──────────────────────────────────────────────────────────────────────────────
KE> I've got a real old Tandy 1000. In order to use the disk drive, i
KE> have to type F3 before it says Starting IB DOS. Is there any way
KE> i can do this automatically in like my autoexec or config or
KE> whatever?
Press the [F3] function key? I don't believe I've ever heard of
that one. Maybe it will only boot from ROM (Read-Only Memory)?
Anyway, in answer to your question, probably not. When you see:
Starting MS-DOS ...
nothing in CONFIG.SYS has even been processed yet. The processing
steps involved in a 'normal' MS-DOS startup is as follows:
:Begin
1) ROM program loads the bootstrap program from disk
2) Bootstrap loads hidden system files and passes control to them
3) ROM programs and the DOS BIOS combine to produce the I/O code
4) DOS system generation begins
5) Does CONFIG.SYS exist?
No - use default DOS values and goto "6)"
Yes - modify DOS default parameters and install user-specified
device drivers
6) Is the command processor COMMAND.COM?
No - Invoke startup portion of the command processsor and
goto "End"
Yes - Invoke startup portion of COMMAND.COM
7) Is AUTOEXEC.BAT present?
No - Issue DOS Date and Time commands and goto "End"
Yes - Perform the commands in AUTOEXEC.BAT
8) Terminate the startup portion of COMMAND.COM
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 13 Apr 96 17:57:22
From: Geoff Cutter Read: Yes Replied: No
To: Bob Morton Mark:
Subj: Unique file name - was JULIAN DATE 2 ENV
──────────────────────────────────────────────────────────────────────────────
On 07 Apr 96 10:12:00, Bob Morton wrote to Geoff Cutter
BM> Unfortunately, I need granularity finer than "minute." It is possible
BM> two files will be created within the same minute, which would result
BM> in identical filenames.
Perhaps reserve a character for incrementing:
set jj=0
:again
REM increment here
if exist xxxxxxxx.xx%jj% goto again
REM unique name found
Several programs can increment - any of these:
BATCHMAN LZH 46761 10/03/94 23:13
FDATE91C ZIP 76262 23/10/95 1:56
GET27 ZIP 117869 31/05/95 19:41
INCVAR LZH 7598 27/11/93 19:08
PSIS-500 LZH 22972 15/05/95 5:00
or you could modify Vernon's batch program:
Date: 07 Apr 94 03:04:11
From: Vernon Frazee
Subj: Auto Backups
The following COUNT.BAT will keep track of how many times it has
been run. Change ALL of the "c:\bat" 's to the name of your
BATch file directory on your system. (Must be in your PATH too).
@echo off
:COUNT.BAT - Increments the COUNT each time run - (Self modifying!) ----
if not (%1)==(/?) goto BEGIN
echo Syntax: COUNT [/0] (Optional "/0" means initialize)
goto END
:BEGIN -----------------------------------------------------------------
set count=1
if not (%1)==(/0) goto COUNT
:Initialize ------------------------------------------------------------
find /v ":%count%"<c:\bat\count.bat>c:\bat\count.bat
goto END
:COUNT -----------------------------------------------------------------
echo :%count%>>c:\bat\count.bat
find /c ":%count%" c:\bat\count.bat>countemp.bat
echo set count=%%2>--------.bat
for %%x in (call del) do %%x countemp.bat
del --------.bat
set count=%count%
:END (Note: COUNT.BAT data storage below) ------------------------ -vjf-
The following example, W.BAT, uses the above COUNT.BAT to keep track
of how many times it has been run. Change whatever you like to suit
your specific requirements:
@echo off
:W.BAT - Loads WORD each time run and also does a "modified
: files only" backup to drive B: every 30th time run.
:Notes - Requires COUNT.BAT and DOS's XCOPY both be available
: somewhere in current PATH.
:Begin --------------------------------------------------------
echo Loading: WORD ...
c:
cd\word
word
call count
echo.
echo Word has been run %count% times since last backup to B:
if not (%count%)==(30) goto DONE
:Backup -------------------------------------------------------
echo.
echo Please insert your "Word Backup Diskette" in drive
echo B: and press any key to begin copying file(s). . .
echo.
pause>nul
xcopy c:\word b:\ /m /s /e
call count /0
:DONE ---------------------------------------------------------
cd\
echo.
:End ---------------------------------------------------- -vjf-
regds Geoff
-!- Blue Wave/DOS v2.30
! Origin: TARDIS BBS (03) 9819 7093 (3:633/260)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 23 Apr 96 11:26:07
From: Vernon Frazee Read: Yes Replied: No
To: Roy Reed Mark:
Subj: DECIMAL TO HEX
──────────────────────────────────────────────────────────────────────────────
RR> Here is a decimal to hex converter, but it's 400 some bytes.
RR> -+-+--------------------------------------------------------
RR> n BREAKOUT.LZH
RR> e100 FC "+"ED BE 82 1 B9 80 FD B4 "?U[VZ"CD "!r`PY"F7 D8 99 ...
How about a simple BATch-file/QBASIC solution:
@echo off
:HEX.BAT ----------------------------------------------
if (%1)==() goto Syntax
if (%1)==(/?) goto Syntax
:Begin ------------------------------------------------
echo A$=HEX$(%1):? A$:system>~tmptmp~.bas
qbasic /run ~tmptmp~.bas
del ~tmptmp~.bas
goto End
:Syntax -----------------------------------------------
echo Syntax: HEX nnn
echo Where: nnn is a Decimal number that you want
echo converted to a Hexadecimal number
echo Note: nnn can be up to nine 9's worth.
:End -------------------------------------------- -vjf-
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 23 Apr 96 11:26:06
From: Vernon Frazee Read: Yes Replied: No
To: Malcolm Campbell Mark:
Subj: JULIAN DATE 2 ENV
──────────────────────────────────────────────────────────────────────────────
AG> In a message originally to Malcolm Campbell, Vernon Frazee said:
AG> :ZIPLOG.BAT - Change to the directory containing the .LOG file(s)
AG> to ZIP and type "ZIPLOG" (no quotes).
MC> I seem to have missed this ;-( Can you please repost?
Here you go:
:ZIPLOG.BAT - Change to the directory containing the .LOG
: file(s) to ZIP and type "ZIPLOG" (no quotes).
:Note: Do NOT put a "@echo off" at the beginning of this file!
:Begin -------------------------------------------------------
@if (%1)==(/?) goto Syntax
@if (%1)==(!!) goto GetMDY
@if (%1)==(!) prompt set date=!! $d
@if (%1)==(!) goto End
@echo off
for %%x in (date mm dd yy) do set %%x=
command /c %0 !>~tmp_01~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
%0 %date%
:GetMDY ------------------------------------------------------
shift|shift
echo;;|choice /c:;%1%; "~tmp_02~ ">~tmp_01~.bat
echo set mm=%%2%%3>>~tmp_02~.bat
echo set dd=%%5%%6>>~tmp_02~.bat
for %%x in (1 2) do echo shift>>~tmp_02~.bat
echo set yy=%%8%%9>>~tmp_02~.bat
for %%x in (call del) do %%x ~tmp_01~.bat
del ~tmp_02~.bat
:Zip'em ------------------------------------------------------
pkzip -ex %yy%%mm%%dd% *.LOG
dir %yy%%mm%%dd%.zip
:Cleanup -----------------------------------------------------
for %%x in (date mm dd yy) do set %%x=
:End ---------------------------------------------------------
Requires CHOICE.COM and maybe 30 bytes free environment space.
MC> Thanks!
Sure; no problem.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 444 Date: 25 Apr 96 17:25:00
From: Ron Warder Read: Yes Replied: No
To: Jerry Dugal Mark:
Subj: count lines in txt file
──────────────────────────────────────────────────────────────────────────────
>I need to count the # of lines in a txt file, any one have an idea on the
>best way to go about doing this?
Here ya go, courtesy of Prof. Timo Salmi, Finlands resident DOS guru:
:: LC.BAT -----------------------------------------------------------
@echo off
echo +---------------------------------------------------+
echo . Count the number of lines in the given TEXT file .
echo . By Prof. Timo Salmi, ts@chyde.uwasa.fi, 6-Dec-91 .
echo +---------------------------------------------------+
rem If no parameters then give the instructions
if "%1"=="" goto _help
rem Check that the file exists
if not exist %1 goto _nofind
rem Count the lines
:: Note: As posted in TSBATxx.ZIP, the line below has an error in the
:: find string. The single "%" should have been "%%", since the single
:: percent sign is absorbed by DOS's batch handler.
:: find /v /c "2O4$fD%h38+" %1
find /v /c "2O4$fD%%h38+" %1
goto _out
:_help
echo.
echo Usage: LC FileName
goto _out
:_nofind
echo.
echo File %1 not found
goto _out
:_out
echo on
:: End of LC.BAT ----------------------------------------------------
This gives you a count of the number of lines in the specified file by
telling you how many lines -don't- contain the string "2O4$fD%%h38+". Any
string will work, so long as it is unique enough to -not- appear in the file
specified. The string given is as unique as any that I have ever come up with.
If the file being operated on contains that particular string, the result from
LC.BAT will be off by the number of lines that contain the search string.
Hope this helps solve the problem ....
-!- SLMAIL v4.0a (#0304)
! Origin: Free Spirit =*= SL/RIP =*= 301-283-0917 =*= V32b/HST (1:109/132)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 437 Date: 24 Apr 96 20:57:24
From: Larry Nelson Read: Yes Replied: No
To: Bill Martin Mark:
Subj: For/in/Do ?
──────────────────────────────────────────────────────────────────────────────
BILL:
Subject: FOR/DO... Clean and Concise explinations?
BM> Can someone offer c clear idea of the usage for "FOR" / "DO". I for BM>
one reason or another am having a problem getting a grasp on this. BM>
Especially when it is used to run multiple functions on multiple files...
Maybe a BM> "easy" example, as well as an intermediate on and an advanced one?
The problem you mention is going to need a recursion routine
but let's start off with a basic For command.
FOR/IN/DO LOOP:
The For/in/Do loop is so named for the three words needed to
make it work. DOS help has a bit to say on the subject and
while that is a good place to satrt there is a good deal
more to know about FOR. For is made up of three main parts.
The call "for", the set "in (.....)", and the command.
for %%q in (this is a for loop) do echo %%q
^ ^ ^^^^ ^^ ^ ^^^ ^^^^ ^ ^
| | |
The call The set (5 strings) The command
For cycles through the 5 strings in this set one at a time with
the help of %%q. %%q is a local variable that takes on the value
of each part of the set in turn.
In people speak one could translate the first cycle of this
For/in/DO loop as "For this do echo this". The next cycle, "For
is do echo is".....and so on. the screen result would be......
this
is
a
for
loop
Echoing a list of words probably isn't the most exciting
thing you have seen a Batch command do so hows about putting
5 file names in the set....
For %%q in (this.com is.bat a.txt for.lst loop.pft) do del %%q
...and now we have a tool that deletes 5 files.
For nibbels at the edges of real loopdom in that it is controled
by the number of strings in the set. The efforts needed to get
any great amount of work out of it, however, boarder on the
gymnastic.
And now to your more advanced question. For can do something
to a bunch of things or it can do a bunch of somethings to
one thing, but it can't do a bunch of somethings to a bunch
of things. Not wothout help that is, and that is where
recursion comes in.
RECURSIONS:
Recursion happens when a Batch file calls itself. Why? You say.
Well one reason a .bat might need to recycle itself is to run
multiple functions on multiple files. For/in/do loops won't nest,
try it and DOS will slap your hands.
This....
for %%q in (dos mail wrk) do for %%a in (*.bak *.tmp) del %%a
will get you this....
FOR cannot be nested
Oh poo! Well not to fret, Recursion to the rescue......
@echo off
cls
if not %1! == ! goto %1
for %%q in (dos mail wrk) do call %0 step2 %%q
goto L8r
:step2
for %%q in (c:\%2\*.bak c:\%2\*.tmp) do del %%q
:L8r
Not so pretty as the line we tried above, but it has the advantage
of not offending Command.com. The first "For" recalls the .bat "%0"
with the parameters "step2" and "%%q" which is "dos", "mail"
and "wrk" in turn. The second "For" processes, in turn, each
directory by deleting each ".bak" and ".tmp" file from the
directory named in that current cycle of For#1. "c:\%2\%%q"
in the first cycle of For#2 reads as c:\dos\*.bak. In the
second cycle it reads "c:\dos\*.tmp"
Neat Huh!
:L8r
Larry
..... In a pinch a stone ax still works.....
-!- Maximus 2.02
! Origin: MSDOS MAXIMUS BBS (1:343/101)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 408 Date: 26 Apr 96 17:38:12
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: 1aday.bat 2/2
──────────────────────────────────────────────────────────────────────────────
[ ...Continued From Previous Message ]
@echo off
:1ADAY.BAT runs a specified program once-a-day only ---------------
if not (%0)==(1ADAY.BAT) 1ADAY.BAT %1 %2 %3 %4 %5 %6 %7 %8 %9
if (%1)==(/?) goto Syntax
if not (%1)==() goto Begin
:Syntax -----------------------------------------------------------
echo Name: 1ADAY.BAT
echo Purpose: Run a specified command only once a day
echo Syntax: 1ADAY program_name/command [parms...]
echo 1ADAY /C clears all entries
echo 1ADAY /? displays this help
echo Example: 1ADAY DEFRAG C: /F /SN
echo Requires: DOS v6.nn+'s FIND.EXE (in current PATH) and
echo 29 bytes free environment space.
echo Important: 1ADAY.BAT is self modifying! It keeps track of
echo when and what was run at the end of itself.
echo Therefore all occurences of "1aday.bat" below
echo must be changed to include the complete path to
echo 1ADAY.BAT. From "1aday.bat" to "c:\bat\1aday.bat"
echo for example.
goto End
:Begin ------------------------------------------------------------
set ~prefix~=:
set ~prefix~=%~prefix~%:!
for %%x in (c C) do if (%1)==(/%%x) goto ClearData
:GetDate ----------------------------------------------------------
echo set ~date~=%%3>~tmptmp1.bat
dir/-p ~tmptmp1.bat|find "~TMPTMP1 BAT">~tmptmp2.bat
for %%x in (call del) do %%x ~tmptmp2.bat
del ~tmptmp1.bat
:Has current command already been run today? ----------------------
find/i "%~prefix~%%~date~%%1%2%3%4%5%6%7%8%9" 1aday.bat>nul
if errorlevel 1 goto Nope
:Yep ----------------------------
echo The command:
echo %1 %2 %3 %4 %5 %6 %7 %8 %9
echo has already been run today.
goto Cleanup
:Nope ---------------------------
echo %~prefix~%%~date~%%1%2%3%4%5%6%7%8%9>>1aday.bat
call %1 %2 %3 %4 %5 %6 %7 %8 %9
goto Cleanup
:ClearData --------------------------------------------------------
type 1aday.bat|find /v "%~prefix~%">1aday.bat
:Cleanup ----------------------------------------------------------
rem for %%x in (prefix date) do set ~%%x~=
:End - Data storage begins below. - Type "1ADAY /?" for info. -----
::!04-23-96dirg:\*.*
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 419 Date: 26 Apr 96 12:57:21
From: Michael Barnes Read: Yes Replied: No
To: Jason Laviska Mark:
Subj: Command line arguments
──────────────────────────────────────────────────────────────────────────────
Jason Laviska wrote in a message to All:
JL> Is there a way to transmit the entire list of command
JL> parameters to a program which will allow me to use more than nine
JL> arguments using a batch file in dos 6.x? Right now all I have
JL> is...
JL> @Echo off
JL> C:\LASRCOMP\LASRCOMP.EXE %1 %2 %3 %4 %5 %6 %7 %8 %9
JL> If Errorlevel==0 Echo Files are identical
JL> If Errorlevel==255 Echo Files are different
'Lo Jason,
Yes, use the shift command. (as in the example below)
but first.. you must list your errorlevel checks in reverse order- such as:
IF ERRORLEVEL 255 GOTO ERROR255
IF ERRORLEVEL 254 GOTO ERROR254
~~~
IF ERRORLEVEL 1 GOTO ERROR001
IF ERRORLEVEL 0 GOTO ERROR000
-!- Now on to the example ---
10PLUS.BAT
:START
IF '%2'=='' THEN SET LASTPARAM=TRUE
ECHO %1>>OUTPUT.TXT
IF '%LASTPARAM%'=='TRUE' THEN GOTO END
SHIFT
GOTO START
:END
TYPE OUPUT.TXT |MORE
-!- So, type:
10PLUS ONE 2 THREE 4 FIVE 6 SEVEN 8 NINE 10 ELEVEN 12 THIRTEEN 14 [ENTER]
and the file OUPUT.TXT will contain all 14 parameters. (the magic is in the
shift)
Sincerely,
Michael
-!- GEcho 1.20/Pro
! Origin: On a clear disk, you can seek for ever (1:271/210)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 439 Date: 26 Apr 96 17:38:10
From: Vernon Frazee Read: Yes Replied: No
To: Ronald Mendoza Mark:
Subj: Random message display
──────────────────────────────────────────────────────────────────────────────
RM> Now what exactly do you mean by "CHOICE.COM" is required in the PATH
RM> somewhere...How do you do this?? ANything special? Or do I just add
RM> "c:\dos\choice.com" to my path in my autoexec.bat???? Please clarify
RM> this for me! Thanks a lot!
At the DOS prompt, you can type:
PATH
to view the directories in your current PATH.
If you keep CHOICE.COM in your C:\DOS directory, (most do), just
make sure the directory:
C:\DOS
is one of the directories in your current PATH.
For example, here is the beginning of my current PATH (displayed by
typing "PATH"):
PATH=g:\key;c:\bat;c:\util;c:\dos;c:\pk;c:\scan
~~~~~~
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- OLMS 2.53p+ [ERSBN55C]
! Origin: SOX! Live from Hialeah_FL_USA (305) 821-3317 (1:135/71)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 440 Date: 25 Apr 96 10:45:48
From: Vernon Frazee Read: Yes Replied: No
To: Jesse Jordan Mark:
Subj: Random numerical stuff
──────────────────────────────────────────────────────────────────────────────
Hello Jesse,
If I've already answered the following, please ignore this dupe.
BBN, "Buggy BossNode" ;(
JJ> Great so far! I have no idea how you got the date in this message,
JJ> but could you get the little split-seconds? I could use that
JJ> variable for the random number. And since it needs to be under 100,
JJ> 60 works great... That way, the role-playing character can start
JJ> low, and work stats up. See, in using seconds, I usually get stats
JJ> like this:
JJ> 15
JJ> 22 <--doesn't take this much time, but the example stands of it
JJ> 35 <--passing from lesser to greater.
JJ> 46
JJ> 56
JJ> It creates them in numerical order as the calls to the
JJ> variable-catching bat are made.
JJ> To speed things up, how about a bat the only catches the
JJ> splitsecond? <I couldn't do it if my life depended on it.>
@echo off
:RND.BAT - Copies the two digit hundredths-of-a-second
: from the current system time into an
: environment variable named RND. Requires
: DOS's CHOICE.COM (somewhere in the PATH) and
: 17 bytes free environment space.
:Begin -------------------------------------------------
ver|time>~rndtmp~.bat
echo set rnd=%%3>current.bat
call ~rndtmp~.bat
del current.bat
echo;;|choice /c:;%rnd%; "current ">~rndtmp~.bat
for %%x in (1 2 3 4 5 6 7 8) do echo shift>>current.bat
echo if not (%%1)==(.) shift>>current.bat
echo if (%%1)==(.) shift>>current.bat
--> echo set rnd=%%1%%2>>current.bat
for %%x in (call del) do %%x ~rndtmp~.bat
del current.bat
echo RND=%rnd%
:End --------------------------------------------- -vjf-
Note: You can simply change the "%%1%%2" in the line marked with
"-->" to "%%2%%1" if you'd rather have the second digit of the
100ths of a second first. For example, as it is, if the
current time was "10:49:15.24a" the RND evar would be "24".
If you reverse the %%1%%2 to %%2%%1, it would be "42".
JJ> Thanks for your help!
Sure, no problem.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate IS the final terminal! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 418 Date: 26 Apr 96 08:36:01
From: Greg Smith Read: Yes Replied: No
To: Jerry Dugal Mark:
Subj: count lines in txt file
──────────────────────────────────────────────────────────────────────────────
For reasons that are still not clear, Jerry Dugal said...
JD> I need to count the # of lines in a txt file, any one have an idea on
JD> the best way to go about doing this?
Here we have one of those cases where we use a DOS command for something
completely different than what it was intended for...
@echo off
:: LCOUNT.BAT - puts line count of specified file into LINES env variable
:: ---------------------------
:: Usage: LCOUNT filename.ext
:: ---------------------------
if (%1) == () EXIT
echo IF (%%1%) == () GOTO RERUN > --------.BAT
echo SET LINES = %%2% >> --------.BAT
echo GOTO EXIT >> --------.BAT
echo :RERUN >> --------.BAT
find /V /C "-[gobbley&gook]-" %1 >> --------.BAT
:: you can use any "string" that you KNOW is NOT in the TEXT file to search.
echo :EXIT >> --------.BAT
call --------.BAT
del --------.BAT
-!- JMail-G 2.80a
! Origin: ACCENT! - Chandler, AZ - (602) 814-7894 (1:114/402)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 429 Date: 26 Apr 96 12:03:11
From: Vernon Frazee Read: Yes Replied: No
To: Jerry Dugal Mark:
Subj: count lines in txt file
──────────────────────────────────────────────────────────────────────────────
JD> I need to count the # of lines in a txt file, any one have an idea
JD> on the best way to go about doing this?
If you mean count all the lines in a text file that:
1) actually contain text (in other words, don't count the
blank lines)
and
2) all the lines of text have at least one space somewhere in
the line
then the following DOS command will work:
TYPE name_of_file|FIND /C " "
If you want to count _ALL_ of the lines in a text file AND you know
that NONE of the lines would contain some strange sequence of
characters like say:
~!1@2#3$4~
the following DOS command will work:
TYPE name_of_file|FIND /C /V "~!1@2#3$4~"
And if you wanted to do something like count only the lines that had
the string "the" in them, either upper- or lower-case, the command
would be:
TYPE name_of_file|FIND /C /I "the"
How many fonts are being loaded in Windows 3.1n's WIN.INI?
TYPE C:\WINDOWS\WIN.INI|FIND /C ".FO"
'Kewl' eh? <g>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Get real, get better, get faster, get Terminate! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 28 Apr 96 11:58:00
From: Benjamin L Mcgee Read: Yes Replied: No
To: Vernon Frazee Mark:
Subj: ERRORLEVEL
──────────────────────────────────────────────────────────────────────────────
BLM> if errorlevel 255 echo 255
BLM> if etc. etc. etc. ...
BLM> if not errorlevel 1 echo 0
VF> How about something just a wee bit shorter (and faster)
VF> than the above 257-line (minimum) monster:
[inspiring code deleted....]
Your code inspired me to pen the following, which seemes to work
fine for me. Do you see any potential (or current) problems with
it. Thanx blm
@echo off
:: EL.BAT blm 1996
:: Set "ERROR" environment variable to last ERRORLEVEL
:: and echo ERRORLEVEL
set error=
set errh=0
set errm=0
set errl=0
for %%h in (1 2) do if errorlevel %%h00 set errh=%%h
for %%m in (1 2 3 4 5 6 7 8 9) do if errorlevel %errh%%%m0 set errm=%%m
for %%l in (1 2 3 4 5 6 7 8 9) do if errorlevel %errh%%errm%%%l set errl=%%l
for %%e in (%errh% %errm% %errl%) do if not "%%e"=="0" set error=%error%%%e
if "%error%"=="" set error=0
set errh=
set errm=
set errl=
echo Errorlevel %error%
Benjamin L McGee on 1:15/7
*FACT: There are more horse's asses than there are horses
-!- FLAME v1.1
! Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 29 Apr 96 18:42:00
From: Jason Laviska Read: Yes Replied: No
To: All Mark:
Subj: Command line arguments
──────────────────────────────────────────────────────────────────────────────
After all useful messages concerning the SHIFT function, I would like to
say thanks to those who have responded with tips and hints. I have pretty much
combined all the messages regarding this topic and ended up using this batch
file below. This message is mainly for those people who helped me, but
couldn't come up with the full solution. If you see any problems with it, let
me know.
@Echo Off
If Exist LCDATA.TMP Del LCDATA.TMP >Nul
If "%1"=="" Goto ERROR
:START
If "%1"=="" Goto RUNLC
Echo %1 >>LCDATA.TMP
SHIFT
GOTO START
:ERROR
Echo No Command Line Parameters!
C:\LASRCOMP\LASRCOMP.EXE /?
Goto END
:RUNLC
C:\LASRCOMP\LASRCOMP.EXE @LCDATA.TMP
Del LCDATA.TMP >Nul
:END
First it will check to see if the temporary exists, and if so, it will
delete it. Next, it will create a file called LCDATA.TMP and store all the
command line variables by looping the command arguments using the SHIFT
command. If there are no arguments were given to the batch file, it will
display the help file for LASRCOMP.EXE using the /? switch. Afterwards, it
will then run the program using the temporary file as its command parameter.
(LaserCompare WILL read the file contents and use it as its command line if you
put a "@" sign in front of it.) In the end, the batch file will discard the
temporary file.
- Jason Laviska
! Origin: _C_E_N_T_R_A_L__S_T_A_T_I_O_N_ * OS/2 * Melbourne,FL * (1:374/31)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 434 Date: 29 Apr 96 05:31:26
From: Vernon Frazee Read: Yes Replied: No
To: Gary Smith Mark:
Subj: ERRORLEVEL
──────────────────────────────────────────────────────────────────────────────
VF> How about something just a wee bit shorter (and faster) than the
VF> above 257-line (minimum) monster:
GS> Your routine is prretty cool, but this one is shorter and uses no
GS> more than seven bytes of environment space.
GS> @echo off
GS> ::
GS> :: Set environment variable EL to the current error level,
GS> :: expressed as a 1-3 digit number (leading zeros suppressed).
GS> ::
GS> for %%h in (0 1 2) do if errorlevel %%h00 set EL=%%h
GS> if %EL% == 0 set EL=
GS> if errorlevel 200 for %%t in (0 1 2 3 4 5) do if errorlevel
GS> 2%%t0 set EL=2%%t
GS> if not errorlevel 200 for %%t in (0 1 2 3 4 5 6 7 8 9) do if
GS> errorlevel %EL%%%t0 set EL=%EL%%%t
GS> if %EL% == 0 set EL=
GS> if errorlevel 250 for %%u in (0 1 2 3 4 5) do if errorlevel
GS> 25%%u set EL=%EL%%%u
GS> if not errorlevel 250 for %%u in (0 1 2 3 4 5 6 7 8 9) do if
GS> errorlevel %EL%%%u set EL=%EL%%%u
GS> echo Error level = %EL%
GS>
GS> Note: indented lines are continuations for the preceding lines, so
GS> there are actually only seven "working" lines in the file. If you
GS> want a result that's always three digits, instead of dropping
GS> leading zeros, remove the two lines which begin "if %EL% == 0".
Pretty cool! Beat my filesize by a single byte. Yours was 444
compared to mine at 445. Went to work on yours though and durn
near whittled 100 bytes, down to 348:
@echo off
set A=0 1 2 3 4 5
set B=%A% 6 7 8 9
set C=errorlevel
set D=) do if %C%
set F=for %%x in (
set G= set E
%F%0 1 2%D% %%x00%G%=%%x
if %C% 200 %F%%A%%D% 2%%x0%G%=2%%x
if not %C% 200 %F%%B%%D% %E%%%x0%G%=%E%%%x
if %C% 250 %F%%A%%D% 25%%x%G%=%E%%%x
if not %C% 250 %F%%B%%D% %E%%%x%G%=%E%%%x
echo %E%
%F%A B C D E F G) do set %%x=
Applied the same technique to mine and it's now at 329 bytes:
@echo off
set F=for %%x in (
set E=errorlevel|%F%A B) do set %%x=0 1 2 3 4 5
if not %E% 250 set A=%A% 6 7 8 9
if not %E% 200 set B=%A%
%F%1 2) do if %E% %%x00 set C=%%x
%F%%B%) do if %E% %C%%%x0 set D=%%x
if (%C%%D%)==(0) set D=
set C=%C%%D%
%F%%A%) do if %E% %C%%%x set D=%C%%%x
echo %D%
%F%A B C D E F) do set %%x=
(Yours displays errorlevels with leading zeros, mine does not).
Of course as you can tell, with these particular variations I wasn't
worried about environment space nor the number of lines. All I was
really concerned with is simply the fewest number of bytes required
to get the job done, (and, using nothing more than COMMAND.COM).
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate is available from a dealer near you! (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 07 May 96 21:12:10
From: Andy Guess Read: Yes Replied: No
To: Larry Kwiatkowski Mark:
Subj: FOR/DO... Clean and Conc
──────────────────────────────────────────────────────────────────────────────
LK->Hokay - I understand the for-in-do function. Could anyone hazard a guess wh
LK->it will not work, for example, in autoexec with multiple "set" commands? Th
LK->has always puzzled me.
For multiple SET's on one line, use:
SET variable1=value1|SET variable2=value2|SET variable3=value3
You can do that as long as the line is less than 128 characters.
Hope I helped!
Cya,
-AG
* SLMR 2.1a * Is this yours? Your dog left it on my lawn ...
-!-
! Origin: * My Place BBS * Bowie, Md USA * V.34 * (301)805-1602 * (1:109/570)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 450 Date: 06 May 96 14:58:47
From: Vernon Frazee Read: Yes Replied: No
To: Joe Kron Mark:
Subj: Text Input HELP!
──────────────────────────────────────────────────────────────────────────────
JK> See PC Mag. 5-25-'93 pg. 299. This is one of many third party string
JK> input utilities. ANSWER is another in The Best of IBM PC Shareware
JK> that puts the string in an EVAR. There is also PC Mag's STRINGS
JK> which does this and more. But I must say the best answer is still
JK> 4DOS.
Why go searching for a third and/or spending money when DOS provides
the capability?
@echo off
:INPUT.BAT puts what is typed next in environment variable INPUT
set input=
echo INPUT.BAT
echo Type in something and press [Enter]
fc con nul /lb1 /n|date|find " 1: ">temptemp.bat
echo :Loop>>enter.bat
echo if not (%%input%%)==() set input=%%input%% %%5>>enter.bat
echo if (%%input%%)==() set input=%%5>>enter.bat
echo shift>>enter.bat
echo if not (%%5)==() goto Loop>>enter.bat
for %%x in (call del) do %%x temptemp.bat
del enter.bat
echo The string you just entered:
echo %input%
echo has been stored in an environment variable named INPUT
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 430 Date: 07 May 96 19:02:00
From: Jeff Brielmaier Read: Yes Replied: No
To: Osgar Schaedtler Mark:
Subj: DETECT IF WINDOWS IS RUNN
──────────────────────────────────────────────────────────────────────────────
OS>Is there a way to detect, in a batch file, if Windows is running?
set|find "windir= >nul
if errorlevel 1 goto NotRunning
....Windows is running....
* KingQWK 1.05 # [PK] * DESQview vs. Windows is a no-Win situation.
-!- FLAME v1.1
! Origin: HAL-PC - (713)963-4100 (1:106/4100)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 431 Date: 05 May 96 10:08:00
From: Horst Schaeffer Read: Yes Replied: No
To: Vernon Frazee Mark:
Subj: ERRORLEVEL
──────────────────────────────────────────────────────────────────────────────
-=> quoting Vernon Frazee to Gary Smith (29 Apr 96) <=-
VF> [....]
VF> Applied the same technique to mine and it's now at 329 bytes:
VF> @echo off
VF> set F=for %%x in (
VF> set E=errorlevel|%F%A B) do set %%x=0 1 2 3 4 5
VF> [....]
Wow! But what shall I do with the rest of the 32Kb cluster?
Wouldn't it be more useful to have a routine that's simple and
easy to understand? For example:
@echo off
set !=
for %%h in (0 1 2) do if errorlevel %%h00 set EL=%%h
if not errorlevel 200 set !=6 7 8 9
for %%t in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%t0 set EL=%EL%%%t
if not errorlevel 250 set !=6 7 8 9
for %%u in (0 1 2 3 4 5 %!%) do if errorlevel %EL%%%u set EL=%EL%%%u
echo %EL%
set !=
set EL=
No fluff to save space ;-) ... and only 316 bytes.
VF> ..... displays errorlevels with leading zeros, mine does not
Would require minor modifications (+24 bytes) - but I prefer to
leave it as simple as it is.
Horst.
... Q4FM 2.10a ... horst@confusion.rmc.de
-!- FM 2.02 / ScanToss
! Origin: Don't follow leaders! (2:2480/13.75)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 12 May 96 23:40:02
From: Raphael Neve Read: Yes Replied: No
To: John Medland Mark:
Subj: deleteing the undeletable dir
──────────────────────────────────────────────────────────────────────────────
Following up a message from Malcolm Campbell to John Medland:
JM=> I had this problem a year or so ago and it's come back to haunt
JM=> me. Some one had given me a solution but I've lost the message
JM=> now. The problem:
JM=> A directory has been renamed using an illegal name.
JM=> Dos can't delete or rename the dir. No programs can delete it
JM=> either. It was named c:\max\cbv, but the name has been changed to
JM=> c:\max\cbv á. Anyone?
if you really want to get radical, you can always use a disk sector editor to
delete the file "by hand" :) seriously... all you have to do is:
a) load up your favourite sector editor
b) search for a distinguishing string (the directory name in question (CBV) or
any other file in the same directory... make sure you do all capitals
c) make sure you've got the right file / directory name
d) check again
e) kneel down in front of the computer and call upon the computer gods to
protect you
f) cross fingers and touch wood
g) replace the first character of the file or directory name by E5
h) make sure you don't change anthing else
h) save and quit
check you did it right by doing a dir. if you still see it and you're sure you
saved, then you've done something wrong and the results are unpredictable. if
you don't then you're well on your way to becoming a die-hard-disk-sector-
editor guru. then run scandisk to get rid of the lost clusters (ie all the
stuff that didn't get unlinked when you got rid of the directory or file
"manually")
note: kids, don't do this at home!!!
raph.
p.s. this is accurate: in a nutshell, dos recognises files that are deleted
from those that aren't by checking if the first character of a filename /
directory name is 'e5'. when you delete a file, all that happens is this
character gets written in the fat on top of the first character of the filename
(well, actually the associated clusters are freed too but that's nothing to do
with the fat). anyway... by writing this character in there yourself, you
effectively delete the file.
... Buy Stacker? Why not just delete Windows?
-!- FMail 0.96Γ
! Origin: Canada Dry BBS - France * 3 lines on 47.29.33.85 (2:321/1)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 14 May 96 20:15:46
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: errorlevel
──────────────────────────────────────────────────────────────────────────────
LN> Here's my 2 bits worth.
LN>
LN> ::ERR.BAT/DOS6.20
LN> :: Tested through errorlevel 26
LN> @echo off
LN> cls
LN> for %%h in (0 1 2) do if errorlevel %%h00 set L=%%h
LN> for %%t in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %L%%%t0 set L=%L%%%t
LN> for %%u in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %L%%%u set L=%L%%%u
LN> echo errorlevel=%L%
LN> set L=
LN> :L8r
LN>
LN> Less code, no temp files, 1 envar, and 280 bytes.
LN> :L8r
A measly 7 more bytes and you get 'em all:
@echo off
set e=Errorlevel|set !=|set p=for %%t in (0 1 2
%p%) do if %e% %%t00 set L=%%t
if not %e% 200 set !=6 7 8 9
%p%3 4 5 %!%) do if %e% %L%%%t0 set L=%L%%%t
if not %e% 250 set !=6 7 8 9
%p%3 4 5 %!%) do if %e% %L%%%t set L=%L%%%t
set !=|set L=|set e=|set p=|echo %e%=%L%
<g>
-!- Terminate 4.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 441 Rec'd Date: 22 May 96 18:04:53
From: Vernon Frazee Read: Yes Replied: No
To: Bat Lang Mark:
Subj: FOR/DO... Clean and Conc
──────────────────────────────────────────────────────────────────────────────
VF> for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
VF> If you'll watch DOS process this line, you can see it doing
VF> exactly the same thing as the above four individual lines
VF> SET TEMP=C:\TEMP
VF> SET TMP=C:\TEMP
VF> SET LIST=C:\TEMP
VF> SET AHDTMP=C:\TEMP
BL> Which is faster in execution, your first quoted line, or?:
BL> SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
To slow them down enough to be able to even time them, I did 10
iterations of each. IOW,
@echo off
:FORINDO.BAT
for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
for %%x in (TEMP TMP LIST AHDTMP) do SET %%x=C:\TEMP
... 10 of these for-in-do's ...
@echo off
:SET-EACH.BAT
SET TEMP=C:\TEMP
SET TMP=C:\TEMP
SET LIST=C:\TEMP
SET AHDTMP=C:\TEMP
set temp=c:\temp
set tmp=c:\temp
set list=c:\temp
set ahdtmp=c:\temp
SET TEMP=C:\TEMP
SET TMP=C:\TEMP
SET LIST=C:\TEMP
SET AHDTMP=C:\TEMP
... 10 sets of these groups of four ...
@echo off
:ALLON1.BAT
SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
SET TEMP=C:\TEMP|SET TMP=C:\TEMP|SET LIST=C:\TEMP|SET AHDTMP=C:\TEMP
... 10 of these lines ...
I then ran each 10 times and averaged the elapsed times. Results:
BATch file Elapsed Time
------------ -------------
FORINDO.BAT 1:59 seconds
SET-EACH.BAT 1:37 seconds
ALLON1.BAT 10:99 seconds
Yep, I couldn't believe it either. <G>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 419 Date: 23 May 96 16:49:56
From: Vernon Frazee Read: Yes Replied: No
To: Jesse Block Mark:
Subj: Bat Needed!
──────────────────────────────────────────────────────────────────────────────
JB> The other day, we were tring to make a Batch file that would comb
JB> through an ASCII file and pullout all the web address, then, put
JB> them into another ASCII file called NET.TXT. We found this could
JB> do it from MS_DOS 6.22:
JB>
JB> for %f in (*.txt) do find "http:" %f > net.txt
JB>
JB> but for some reason, we couldn't use this in a batch file. It kept
JB> coming back "syntax error" but it worked fine from a dos prompt. So,
JB> here's my problem:
JB>
JB> 1. Can this be done as a batch file in a different way?
JB>
JB> 2. What did I do wrong that _this_ wouldn't work?
DOS strips one of the percent signs when for-in-do is being used in
a BATch file. Therefore, if you'll change both occurances of "%f"
to "%%f" it should work just fine.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 407 Date: 23 May 96 10:24:40
From: Richard Epling Read: Yes Replied: No
To: Alan Milewczyk Mark:
Subj: Capturing date in a batch
──────────────────────────────────────────────────────────────────────────────
From: Alan Milewczyk Time: 05-19-96 13:30:30
> I want to be able to capture today's date into a batch file to enable
> me to copy files in a specific directory with the attribute flag set.
> How do I capture the date and pass it over to the copy file routine.
I don't understand how you would use the date to copy the files but I'm
assuming you do. One way you could do this would be to get the output of a
DATE command into a temporary batch file which you could then use to run
another batch file to do what you want to do. For example;
@ECHO OFF
ECHO.|DATE|FIND /I "CURRENT">TEMP.BAT
That will put the line "Current date is Thu 05-23-1996" into TEMP.BAT.
You can then either have a batch file name CURRENT.BAT to do the work, and
CALL TEMP.BAT or ECHO the commands you want to CURRENT.BAT. For example to
set an environment variable with the current date you could continue the
above example with these lines;
ECHO SET D8=%%4>CURRENT.BAT
CALL TEMP.BAT
That will give you an environment variable you might be able to use in your
other batch command. Note the double percent sign is required here. The
contents of CURRENT.BAT would be "SET D8=%4." CALLing TEMP.BAT would cause it
to run CURRENT.BAT which would set the variable for you. Hope this is what you
need.
Richard
-!- FreeMail 1.09
! Origin: Electric Eye-28.8 Sacramento,CA(916)441-5465 (1:203/65)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 449 Date: 27 May 96 00:00:00
From: Mike Zeleski Read: Yes Replied: No
To: Robin Chapple Mark:
Subj: Where To Start?
──────────────────────────────────────────────────────────────────────────────
RC>Greetings To All!
RC> I'm wanting to learn more about batch file programming.
RC> Where does a 'know nothing' start?
With the basics... :-}
RC>Is there a file I can download?
Several, notably you should look for MUF17, and any one of several Batch
programming tutorial that exist on the Nets...
RC>Is there a good book that I can buy?
Several, however you should already have a good one already...
Your Dos Manual, and the Dos Help program. While they are not
particularly batch specific, they will help a lot.
The other features of BFP are not all that bad to master.
Excluding ordinary Dos commands, BFP just adds a few instructions,
labels, and variables to the mix...
Lets see...
%1-%9 are handled much like Dos command line variables,
There is a IF (?) command, Labels to go to, and several other bits...
See below for a few examples. This little bit is notoriously short on
how to's beyond the vary basic minimums, but frankly let's discuss them
later when you have specific questions to ask...
[Start Mike's BFP MiniFaq.]
Batch file program is based on the simple conjecture that it is easy to
create a user readable text file program/utility that simply stacks Dos
commands together with just a few special BFP commands to do actions
like move a file or create a directory and move to it without having to
create a program to do so from scratch...
This can be a simple way to automate anything that you do more than
once. With a few external Batch programming aids, the use of command
line variables, internal variables, Qbasic calls, stacked commands,
errorlevel jumps, Labels, and Goto's these "little" programs can get
quite sophisticated and complicated in a hurry.
However BFP is best when kept to the basics for most mundane everyday
uses, as in good engineering KISS is the word. As a tip I often use a
little batch file that dumps doskey's remembered commands into a little
batch file and immediately edit it like so.
Qckbat.bat (Use D:\path\xxxxxxxx.bat CM parameter)
DOSKEY /HISTORY > %1
EDIT %1
This little example dumps past instructions into a batch file and
immediately sends you into edit to make some small changes to that
batch file. (You must have doskey loaded to make this work.)
I also used a Batchfile program to present a nice menu with ansi.sys
commands and a external utility to run my most frequently used programs
from. I did this to even run some Windows programs or plain Windows by
itself. Did you know that you can start Windows and run a Windows program
immediately from the commandline...
In fact here are a few clips from that menu, (If you want the entire
thing including the utility I used to use, Netmail me.) One of the
below clips includes the most efficient defrag command line I know of.
It's only a few percent better than a simple consolidation, but what the
hay, you might as well do it right...
[quote mode on.]
:run_defr
C:\d\defrag C: /F /S:E
goto restart2
:run_qmdm
win c:\qmpw\qmwin qmwin.phn 1
rem This little string starts Windows, my old Q-modem terminal program,
rem calls my main bbs mail #, and it's attached script. Mail run.
rem Automation! 3 command line parameters for two different programs.
goto restart
:winstart
win
rem Run Windows.
goto restart
:wp_60
win C:\wp60\wp
rem Same as above with Word Perfect 6 for windows.
goto restart
:win_word
win C:\winword\winword.exe
Rem Yes, I do Microsoft apps. But you should hear the wave file attached
rem to this program's start up it. Ahooga.wav
goto restart
:Gramtx_5
Win: c:\gmkw\gmkw.exe
rem sometimes we use bad english, don't we...
goto restart
[quote mode off.]
Some other useful examples...
MDCD.BAT (Use xxxxxxxxxxx directory name CM param.)
MD %1
CD %1
This little BFP creates the directory and moves you directly into the
directory that it just created. Use just like you would use both MD &
CD, but it combines them into just one command...
Header.bat (Use D:\path\xxxxxxxx.txt CM parameter.)
@Echo (One line of text here) > JUNK.txt
copy JUNK.TXT + %1 %1
del junk.txt
This little installs adds one line of prespeficified text into the
beginning of every file indicated as the commandline parameter.
If you want to add more than one line then you do it this way...
Header.bat (Use D:\path\xxxxxxxx.txt CM parameter.)
@Echo (One line of text here) > JUNK.txt
@Echo (Next line of text here) >> JUNK.txt
Rem Repeat the echo as many times as needed.
rem One arrow means make the file, two means add to it, aka append.
copy JUNK.TXT + %1 %1
del junk.txt
Trailer.bat
@Echo (One line of text here) > JUNK.txt
@Echo (Next line of text here) >> JUNK.txt
Rem Repeat the echo as many times as needed.
rem One arrow means make or overwrite the file, two means add to it, aka
rem append.
copy %1 + JUNK.TXT %1
del junk.txt
There are some good BFP FAQ/tutorial files floating around out on the
BBS's, as is the excellent MUF 1.7 file. I suggest you grab them...
-!-
* OLXWin 1.00b * Always tell her she's beautiful, especially if she isn't. RAH
-!- WILDMAIL!/WC v4.12
! Origin: Father & Son*610-439-1509*Whitehall Pa (1:2607/112.0)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 30 May 96 09:04:27
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Errlevel.exe
──────────────────────────────────────────────────────────────────────────────
VF> I almost sent you the following little ERRLEVEL.COM (& .DOC) in my
VF> last message to you. It sticks whatever errorlevel you want in
VF> memory so you can then test for it with your BATch file.
VF> ----------------------------->CUT HERE<-----------------------------
VF> NERRLEVEL.ZIP
LN> TKS, Rat.com worked but it was a long way around. Am now waiting for
LN> the sh*t storm when these guys discover that we might actualy stoop
LN> to extraDOS utilities on the odd occation.
<g>
LN> Has any body actualy found where in memory the errorlevel data is
LN> stored?
Here, try this -- stick an exit code in memory that can then be
tested for with one of the EL.BAT files floating around:
1) Put what's in this Everything in this column
column into a file is merely a comment and
named GETKEY.SCR: should not be in the file
------------------ ----------------------------
N GETKEY.COM Filename will be GETKEY.COM
A Toggle into assembler mode
MOV AH,00 BIOS read a character and
INT 16 put its ASCII code into AL
MOV AH,4C Ready to exit with code so
INT 21 do it
Toggle out of assembler mode
RCX Read register CX and
8 stuff file size into it
W Write the file to disk
Q Quit DEBUG
(Note: Make sure you leave the blank line between "INT 21" and "RCX"
to toggle DEBUG back out of the assembler mode).
2) Create the program GETKEY.COM by typing:
DEBUG<GETKEY.SCR
3) To test it type:
GETKEY|EL
and then press say the [Esc] key. You should get an errorlevel
of 27 -- the ASCII code for the Escape character. Now try it by
pressing say [Shift-A] (uppercase A) and you should get an
errorlevel of 65. Lowercase "A" would be 97, etc., etc., etc.
Or, you could even use it in a BATch file that would only exit to
DOS if you pressed say the [Enter] key (ASCII 13):
@echo off
echo Press the [Enter] key to exit to DOS
:Loop
getkey
if errorlevel 13 if not errorlevel 14 goto End
goto Loop
:End
(Note: Both DOS and your system's BIOS can process keystrokes. This
particular example uses the BIOS but it's just as easy to substitute
a DOS function call. In fact, DOS is better for some things because
it offers several options. It can display the character you entered
or discard it, wait for a keystroke or process one only if it's
there waiting, and it can handle break attempts or ignore them).
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 439 Date: 30 May 96 14:27:00
From: Roy Reed Read: Yes Replied: No
To: All Mark:
Subj: filenames with numerical extensions
──────────────────────────────────────────────────────────────────────────────
If anybody has a series of files with all digit extensions, I
made the following two batch files to enable switching back
and forth between having or stripping leading zeroes in their
extensions (i.e., renaming the files by changing the extension).
These batch file names may be called whatever_you_want.bat
Rejoin word-wrapped command sentences at the dollar signs, then
delete the dollar signs.(Two sets per file)
------------------------------------------------
::lead000.bat
@echo off
if "%1"=="pancakedough" goto pancakedough
if "%1"=="" goto syntax
set fn=%1
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.%%x ren %fn%.%%x %fn%.00%%x
for %%x in (0 1 2 3 4 5 6 7 8 9) do call %0 pancakedough %%x
goto end
:pancakedough
set k=%2
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.%k%%%x ren %fn%.%k%%%x %fn%.0%k%%%x
goto end
:syntax
echo enter lead000 file_basename
:end
set k=
------------------------------------------------
------------------------------------------------
::nolead0.bat
@echo off
if "%1"=="pancakedough" goto pancakedough
if "%1"=="" goto syntax
set fn=%1
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.00%%x ren %fn%.00%%x %fn%.%%x
for %%x in (0 1 2 3 4 5 6 7 8 9) do call %0 pancakedough %%x
goto end
:pancakedough
set k=%2
for %%x in (0 1 2 3 4 5 6 7 8 9) do if exist $$$
$$$ %fn%.0%k%%%x ren %fn%.0%k%%%x %fn%.%k%%%x
goto end
:syntax
echo enter nolead0 file_basename
:end
set k=
------------------------------------------------
For example, if you have file.1 through file.25, entering
a command of lead000 file will leave you with file.001
through file.025. To put them back to original names,
enter nolead0 file
Roy
! Origin: The GIFfer BBS, 75+gig, (813)969-2761 (1:377/50)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 421 Date: 03 Jun 96 15:12:36
From: Vernon Frazee Read: Yes Replied: No
To: MIKE DUTTERA Mark:
Subj: Capturing date in a batch
──────────────────────────────────────────────────────────────────────────────
AM> I want to be able to capture today's date into a batch file ...
VF> @echo off
VF> :Sticks the current date in evar DT
VF> echo set DT=%%4>current.bat
VF> ver|date>~.bat
VF> for %%x in (call del) do %%x ~.bat
VF> del current.bat
MD> Okay, tryin' ta learn here. (Oh No! He says!<G>)
We ALL started in the exact same predicament. <g>
MD> How and/or what is being parsed in what fashion that so you
MD> magically gets the date into %%4? Tisn't immediately obvious. I'd
MD> like to see why this worked as maybe it might come in handy someday.
MD> Thanks, Mike
The line that begins with "echo" puts the following string:
echo set DT=%4
into a file named "CURRENT.BAT". (DOS automatically replaced the
two percent signs to one).
The next line, the one that begins with "ver|date", will put
something similar to the following:
Current date is Mon 06-03-1996
Enter new date (mm-dd-yy):
into a file named "~.BAT".
The next line, the one that begins with "for", first CALLs
(launches) ~.BAT. Because the first word inside ~.BAT is "Current"
it subsequently launches the CURRENT.BAT with the command line:
Current date is Mon 06-03-1996
|~~~~~~ |~~~ |~ |~~ |~~~~~~~~~
0 1 2 3 4
As you can see this command line will pass the string "06-03-1996"
as the 4th parameter which CURRENT.BAT will then put into an
environment variable named "DT".
The "del" (in the same line beginning with "for") is the next
command DOS will carry out which gets rid of our temporary ~.BAT.
The very last line gets rid of the temporary CURRENT.BAT ...
and all we're left with is the following in the environment:
DT=06-03-1996
Pretty slick eh? <g>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 437 Date: 04 Jun 96 15:27:22
From: Vernon Frazee Read: Yes Replied: No
To: Evelyn Brown Mark:
Subj: COUNTING
──────────────────────────────────────────────────────────────────────────────
EB> I read and used your COUNT.BAT and COUNTTO.BAT and all worked
EB> as you said it would. I've been wondering for a long time how to put
EB> values into the environment without using SET. I did add one "call
EB> count /o" at the beginning of COUNTTO.BAT and now when I interrupt
EB> execution with CTRL-C it will start again from zero. I got into a
EB> loop that kept going higher, even after it passed the value I
EB> entered with COUNTTO.BAT. Now for the real reason for my message. I
EB> don't understand what the batch files are doing. If you could
EB> possibly walk me thru both of them, step by step, I would greatly
EB> appreciate it. I'm not a beginner at batch files, but I don't know
EB> the "innards" of DOS well enough to use its real power. Thanks in
EB> advance - Evelyn Brown Houston - HAL-PC BBS
Before we delve into each line here, each time COUNT.BAT is launched
(without its "/0" (initialize parameter)) it appends another line to
itself. Each line appended contains the following two characters:
:1
All we then have to do to find out how many times COUNT.BAT has been
run is use FIND's "/c" (count) parameter -- like so:
FIND /C ":1" C:\BAT\COUNT.BAT
If COUNT.BAT had 16 lines containing a ":1", FIND would display:
---------- C:\BAT\COUNT.BAT: 16
That's really all there is to it.
Of course, if you'd rather display something a little less confusing
you could then:
1) Capture FIND's output to a temporary BATch file, say named
COUNTEMP.BAT:
FIND /C ":1" C:\BAT\COUNT.BAT>COUNTEMP.BAT
2) Create another temporary BATch file named "--------.BAT" (eight
dashes) that will place its second command line parameter into a
temporary environment variable, say named COUNTEMP:
ECHO SET COUNT=%%2>--------.BAT
3) If we now launch COUNTEMP.BAT its first word is ---------- which
subsequently launches --------.BAT with a command line of:
---------- C:\BAT\COUNT.BAT: 16
4) --------.BAT then sets environment variable (evar) "COUNT=16"
with its command line of:
SET COUNT=%2
5) Now display what's in evar COUNT with the line:
echo Count=%COUNT%
6) And all that's left to do is cleanup our temporary files.
FOR %X IN (COUNTEMP --------) DO DEL %%X.BAT
Now on to your request:
01 @echo off
02 :COUNT.BAT - Increments COUNT evar each time run - (Self modifying!)
03 :
04 :Note: All occurrences of "c:\bat" below must be changed to match the
05 : "drive:\directory" where you will be storing this Count.BAT.
06 :
07 if not (%1)==(/?) goto Begin
08 echo Purpose: Increments COUNT environment variable each time run.
09 echo Syntax: Count [/0] (Optional "/0" means initialize)
10 goto End
11 :Begin -------------------------------------------------------------
12 set count=1
13 if not (%1)==(/0) goto Count
14 :Initialize --------------------------------------------------------
15 find /v ":%count%"<c:\bat\count.bat>c:\bat\count.tmp
16 copy c:\bat\count.tmp c:\bat\count.bat>nul
17 del c:\bat\count.tmp
18 set count=
19 goto End
20 :Count -------------------------------------------------------------
21 echo :%count%>>c:\bat\count.bat
22 find /c ":%count%" c:\bat\count.bat>countemp.bat
23 echo set count=%%2>--------.bat
24 for %%x in (call del) do %%x countemp.bat
25 del --------.bat
26 echo COUNT=%count%
27 :End (COUNT.BAT data storage begins on the next line below). - -vjf-
[...continued in next message...]
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 04 Jun 96 15:29:29
From: Vernon Frazee Read: Yes Replied: No
To: Evelyn Brown Mark:
Subj: COUNTING
──────────────────────────────────────────────────────────────────────────────
Line 01: Flips the echo off which keeps DOS from displaying each
line of the BATch file as it is being executed. The leading
"@" symbol keeps DOS from displaying the actual "@echo off"
line before it gets a chance to toggle echo off.
Line 02: The ":" symbol is usually used to tell DOS that a line is a
LABEL (as would be used in the BATch command "GOTO LABEL").
It's used here simply to keep DOS from trying to execute
the line because it's being used for a comment instead.
Line 03: Blank line comment used as a visual divider.
Line 04: Again, since the line begins with a ":" DOS thinks it's a
LABEL and ignores it for now. (Hence we can also use ":"
to start our comment lines).
Line 05: Continuation of the comment beginning on line 04 above.
Line 06: Blank line comment used as a visual divider.
Line 07: Check to see if the user entered a command line parameter
of "/?". If they did NOT, it's jumps to label :Begin. If
they did, it falls through to the next line ...
Line 08: displays the first line of the brief 2-line help,
Line 09: then the second line of the brief 2-line help, and
Line 10: then jumps to label :End.
Line 11: Label :Begin. (BTW, DOS ignores everything after a space
(and anything beyond 8 characters if there isn't a space)).
Line 12: Set an environment variable named "count" equal to 1.
Line 13: If the user did NOT enter a "/0" on the command line, jump
to the line label :Count, else ...
Line 14: fall through to line labeled :Initialize. (IOW, we're
preparing to reset the count to 0).
Line 15: Environment variable "count" currently contains a "1".
FIND's "/v" parameter means DON'T find something.
Therefore, the command:
find /v ":%count%"<c:\bat\count.bat>c:\bat\count.tmp
means: "Yo! FIND, using C:\BAT\COUNT.BAT as input, (the
'<c:\bat\count.bat' part), look for all the lines
that do NOT (the '/v' parameter) contain the two
character string ":1" (what's in evar 'count'
prefixed with a ":"), and, instead of displaying the
results on the screen, write 'em to a file named
C:\BAT\COUNT.TMP (the '>c:\bat\count.tmp' part)."
Line 16: Copies the temporary file C:\BAT\COUNT.TMP over top of
C:\BAT\COUNT.BAT. (IOW, any lines that were in
C:\BAT\COUNT.BAT are now missing because we used FIND to
search for everything but some unique something).
Line 17: Delete the temporary file C:\BAT\COUNT.TMP.
Line 18: Remove evar COUNT from the environment.
Line 19: Goto line labeled :End. (COUNT.BAT has been initialized).
Line 20: Beginning of the Count routine
Line 21: Append the two character string ":1" to C:\BAT\COUNT.BAT
Line 22: Use FIND's "/c" parameter to count the number of lines in
C:\BAT\COUNT.BAT with the string ":1" (what's in evar COUNT
prefixed with a ":")) and send the results to a temporary
file named COUNTEMP.BAT.
Line 23: Put the string:
set count=%2
into a file named --------.BAT
Line 24: First, CALL COUNTEMP.BAT and then DELete it.
Line 25: DELete --------.BAT
Line 26: Display the number left in evar COUNT by --------.BAT.
Line 27: And that's it, we're outta here.
BTW, when there are a mess of
:1
:1
:1
:1
lines at the end of C:\BAT\COUNT.BAT, DOS will ignore them because
they each begin with a ":" -- line labels.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 05 Jun 96 14:04:58
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Errorlevel.exe
──────────────────────────────────────────────────────────────────────────────
The enclosed SETEL.COM (along with SETEL.DOC) is actually a XEQ.COM
(v1.15 COM File Library and Command Executor) containing all 256
6-byte errorlevel-setting COM files. Storing them this way instead
of individually can save tons of room on your hard drive.
Each of the 256 .COM files within SETEL.COM can be executed in place
(while still within SETEL.COM) and each will still do exactly the
same thing -- place the errorlevel indicated by their filename into
memory. e.g., SETEL 96 will place errorlevel 96 in memory.
[...Part 1 of 2 of file SETEL.SCR...]
----------------------------> CUT HERE <-----------------------------
NSETEL.RAR
E100 FC "+"ED BE 8B 1 B9 F5 FD "+"DB 8B D6 B4 "?"CD "!riP"8B DE 8B
E117 C8 AC "<*"E0 FB "uP"B4 1 80 F4 1 "<"A AC "u"FB "<>t"F4 A E4 "u"
E130 F3 E8 "'"0 "*"F6 3 EA FE C6 B1 4 AC "< v"E3 E8 17 0 2 D2 2 D2
E148 B5 6 D1 E2 "s"5 88 "7C"B6 1 FE CD "u"F3 E2 E3 EB DF 8A D0 BF
E15E 80 1 2 "U"FF "*"15 "r"7 AE "r"4 AE "s"F3 C3 "XZ"B9 FF FF F7 DA
E175 B8 1 "B+"DB CD "!"8B CD CC 0 "+,-.0:A[a{"FF
G=100
W18B
Q XDS 1.3mp by Horst Schaeffer
*XXBUG20--000016AE--04061996--FD5DABFC------------------SETEL.RAR
nIa3m6Fc5+1jEQkU+1E++++++++-FULE+U0Y+FlA++0QN++++NB134E+6kG+DBEY+6+++
n+3B3J2JA9YBDHEzPqOjiTR5MPbUjf992b2TlK+Djzsfyz2pj1tC6OTtySl2waxkrTyjA
nSImhbrzbLRTWctmLa7KUYQl5rRtTFvayVM-yGNh8CBbb+XOufrkM8sVUkRenhA+z0QgH
noIxkFykabQG2S2Es2v2-iF6wV-VTD+DPBPJcSntNECQzoRbBn1hNB5Dm4urRyaDU6X7z
njNo59HZBncJ5zZtWtZe8Xrp6lQUyTVvD1CLA7WsRtgIEZTOyP-xaPEzaHIkzIz3iB8o1
nWV3oUd-Y7wpzbYaXu13zpODmAjGoP7uztUokmiOrUpUMzX93DsYMurGH+z2pZcVTe3oT
nEyWqQffwzgD-2iwS+RSMPPqYzi-kHqJK6ObLaAa1-5yb+S+dHH1zY3rECxVPC8ULiYm-
n0j1nMqlbi-uWKFllDTdCKwgiAzFaD00+ksbP1wknk+4tR0ELi5weA0Gs2Pnses48SIGB
n1OULqHMdqFgyTlK6khCFmTbLRE1BIz2gjJ-HAzKDdmd8-zu2-x-r-GDsVcdQ1cunZVB+
n4ITnYSG1GCCeBzjuOAOY1EEAtmX3+x80eaCt6Td0VUPf-T3bQxDYrG-BtuLE9y-Ijwkf
naOAfUUk6pAcv+Qqy6M0d+x0HdTnuuQQA7pxlQCEY5Ieo7IXP8RNi62UFOXoUZon5zlYw
nYx0NDJ+nDDpZ123RkM21V1FRO8RtRA4zE4x9BfAja9L5lBZ3pKQMJTZ7zsvYhUWP5M+C
nIeRQIpxmULztG6wjh25xv9-VvDFHdDsOa1YTRtTMZyNc-Q-ctCGBteCceQcfZv90dZ8s
ndcwxawgLFuQgc14uIcYdf11d6Ti0O75k9+dCtSQNrFV5icpE9YY+ScM68OuAGB2dQwgz
nE7YcZfkdrK60JEhDtGPfd5mFrjVl7fUWW4WtvClVjAQ53KO89+6WcdQZJ80E-2bUQQCs
n8iRO6Mi-lhIr4J2eJpFoduQ83-ckQJQM7bP4+MvaV61vx66rdOSmA8sGRlW7qH2SMtB2
nNa6Et-TxYrFGb4dde5sf6YKB5CuGApJYgun3rhuMztAzjZRf4-5zQia5qwSwNvYOXYu6
n+O1FLrQ14TkGV7LknBQPk4ikQRkdFQqdDhH8Q7moKTyzfgozoTPyvdKYiggAwXBnn1QV
nP4IB5wtSQ3qmMsXIPWF3USZkW-HWrDq4yQqiHBNbRFYhR07ryFgQnh9QHf9qcalzceF+
nkT+Kt6CGecN8I2ijRcoG7zqVGXbgMIeflhBYB4u5Tiu6TCe3vm0b6kNbWHEeH0uyE7Z+
nw10xTqLQxsHd8+k7Ea7ZCMvxlPjay87diEeqJUm2xVComH51zb8J9xEVGwF9Y-i7HtPj
ni6T+NNR5mCmYCf+ul3aieaUbCq70Mb6GfL2ETy7lgpuGhZpJBJclJgVlxaEMt1X8ctJ7
nytcFvfGmgx0KtNTWHz+GLC0eJoOX70GiE6292XZef4BdTGtm-UKipSg6lRIg3VwYg52j
nsmCbgxPTSAC+HtZdkG4BMFCFkiA73PEcXjHxdkKd76WybExbzfsF-Uyj1w5IHGu9KxUd
nxW0y2Vhtm0M3Ytenq-DtwhDJH0Az8fGgj8PzyV3BnWrvOaRp2QyBdILw7eIlHnFOa6yV
n04QrIXWMYShN5ob1J70Uo8ql7GVraWZ8SkrDHlGNIs78jts5Rja9FKixCUJo44sYe6cf
nu4wyiZYa4D22D0YVYUdygG2b6GEZQKXZu-7TZ0FL5cmOsgLn-1Lz6jeua82d95JDSqDt
n7rYW3Q4X04rR-UioMX0dlIIrmT5YsPrr7bZQecbDAMqIJlcNQXlAVC2xiDJwwD21WgFW
nH59jvXUGMHD1qS5isb5rTBvlHcuh-LynmMDT7-IV9eVDOCs1G5EtPXNI6rs3BxAz1yEZ
nt0dnYLW1fDA9xS5q65xGSCu2dlnXS1mY1Zjd1TFL4q1LlVMnnfvM55PXd4IKLhj2QwgM
nbTQxICgYO6bkYuYh9kSvKGdeO7VAafisSq35pWRkM1I-WPyrH16QFk7apdOf1Y18oni4
nDXm0f7IVWa8SXnMiDm2RooVVLA21f5ZSsjeSdA-MJkPmyosjo+4RjuVhrZDTO8hBMlT-
nnSA8YxehqryXsGMtMKz5qTAkEN11LRPmi5Bp7Sz6yQ-8pLTyZljnFZP2zA+w4oze0Tgn
nyBUBGiqmzbhYoHVAyiiN8EXqphPkLEPmH9SGI4gXcT3AfNB0nqXLsxWSET7RPGIabpNz
nB6Ge1wd7nhjdCuAnzkK2fISUYV92g3AVuDJh8Mk727Vq2TgHtfp4ni5PEiODfEZJgMCI
nEb47V+79PCupA0xu+dSUe4Aka2Q5ABXIGN6IiJBh1p7yCca0fHNj00l4XAeSPIF88gj6
n4lNS9zLtgXRJJ3X8qZxphDqr8ICzooz3mI8Cuvv7c8hY-WSXrCEaWwXGO079I-SZysGM
nHIFjpnrFEki+aALxPzlEXu-zyQITgMJiHqlX0q0oXCOUoaD7h6hBi7s8k7Syl-9Pedra
nV7P3D83hE54GJ+EwZ0mAtiuRxWvxXrqrNkADdri1bTbtsur81iGe-4wJ2byW0fgjxGRV
ns4-psNEGIzay+kwATAa7JRRk0wnyv+wekA4yaXBOMb0taeLmMx+hPKAyVoeloMrQUFLO
nD070Lo5FW4CNe64XwOgqHpLO6efVaPKxtNE7OGeDkgz3aBSKK3jBcPNyI93C0YXWR1o-
nxDabZh9kbXC3eTG-1+bni6qYUPzvqZFRHcVQOWpljeIOK75G0eMgJB883iNQ8gkaEbMB
nLZ2xP47TMhyOoYiEV8ushhGJYVq5ZXMxTzt482PdLOyPbg8afGwluAN9-190efVf9Nwc
nTx541lDawkrG6x-MATdAqFOcwn3bl+om51d4kagysfPV2+G-6vOkLD3i5TFCZt4AVQwl
nKhaViFSj0gPcnISjf7ovTfGaRyWGEFtQ7IPYmCui-jm56QsnWBvtQPVo5aV7X+60Yf8w
nsqIeSPCttwdB7BpYeH-d7yIWQIdcdIwnJpxBM1TMkbpt55k4-zn+W9Apk4P+QdBI7gq6
nSBb24d9IUHq4cXK2rO-Z6aG-OQeVbF8vPd7qMDghY2BOjf3AT5LzonV9snV6Ohlz3usq
ne81Fi3wUMyjrsLNjNhlwOzjAw7EBCeDBQ8l5xzCzwy53IVg6mEqLA2unhaZ-Kip7Jf0H
nBokHYqhOUoKys43qOzClLqqUhXWD22BxXmTJ8-WKS9dWNpGlUDiaw3g5vDzVO9-uUikp
noSQAgGz8wUsjuzUSEdDdWjsVjiQK5vXahx7x6Yi2qweaYQnOk13mg0GzIqIDy3KoGA2O
nfnvgK9Ynru8Cdr5kiTE2Gope7d2ayMffYQby8uHqoJlXtIzhavA9jLM562ekpQ-CPQA6
nQSTWSroBxkS9Da7YMAekozZWy8GAuPJLGHXJ+Q5n3o6snK+mqGGM17mJdjS5jVNT6xfD
nJT3GS+l9l+wxByKGkEVjim5MGpNK9aDqpjxmI2dftr60IVgT0zTchbgtCqGvbS5WNzjQ
nv0-3oNoKPrMHzl9OgLTb2O999VTUZkQzxlL5WG1eUPkka7EO2biJWEvWBRO3z-KgsoA5
nWT91Q6SHl18VoiDlHAX5vh1BlBpCpUalkZnfwu96NDc1VVy58scLy37848Vqy7roDJOz
nemlnueg+TGQYVZPfmX4S7zBApGY4ewQj6FBdY2wLUB4Ufksuzc7OuxC+ZoBr1bmPsCik
nRWjiWgcS9zCNsTSlKSKWzxzBv-4OYT0v8w8XAecf1-ydJREQ7Qj5UEmgQhc0w5t-T6DG
nP+Z3Kvc7C8EwH7cSYncerR3xlbEsrwQNppC-p4TkqTPPqcZRbdDS59shhI-ODvl1xX+Q
nDuX1G+jr13gALwseYUu4ORDRpHLd8OQE4z7ewTasATs4qSKjuj3Ox+NIuC+OQzEYhVH2
nFp34QnwDouDQvGtzTGYr4GmLyYKRFMTxjwFEgfhTlUKuyhxuHxDyRa2PC1CbGQWXzS-Z
n3BF9nyqSW48fqkzbT3vfXu5Wt6dn0yHh+kqY0SjVp0cgU7Q+LzoqLVP1Mvs7D3hrHSkf
nUWmlbddVK6OoBPxdCgexU4JgAYN05svTbj7SuAwLKYkiX+Md3QPCTzWM3TI1LQPwMAnz
nMGLQI0S76qkGNg2WTBlTGGYZ2eGAHS-D2-O3sBEQfLliJjK+wu5ZbgL5aq4CkuclUr8c
nOr9Gq0NjZ2KEi2xGGSMELwYe7zjI4tswGJoGFzArZfNmg+JfdHGqABlCs7dKwcA4EAPo
nlb4-PTZj72wG4nFYR3cTOXFPH7kpIc184vRXEOayc2WkLubcbw6ANXQa582ayBvQ4L9m
[...Part 2 of 2 of SETEL.SCR in next message...]
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 05 Jun 96 14:05:22
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Errorlevel.exe
──────────────────────────────────────────────────────────────────────────────
[...Part 2 of 2 of SETEL.SCR continued from last message...]
nO56J0WNg7hB62h0V7V4VodLBI+SEntPqdGAXa0ohexFtXyK5v7C0Q87ArTn5EFGjWXy6
nHVJzSWTt8ZRGpJoFROKbc4GypQxcGZ5FS2aHE10R+xUYeiFmad2UksUx+ZIH9bMgYH8H
n-lkWWIcGb0JkwhNpAPUQZXBiITzhatj32XQEutdKOWfpCcVGaA9vy2UgYHa0mAz0MOVA
nGqZlL39-lApvz3nCNjCmRWviDjeXg7FfMZJMgOZ4Ud8SPXH7LMoIVqVcYn0TlhQOAx7B
nQ-cHMn6gjocmnyTSYJtUJGLyDsdfMJAbGsi6kV0Mkad6xICaYI435OycwpChFnODnuop
nqFn7wrzFb11aRK1qINtxY4MOSFqIYWbYRAGDsO7YMmQjAbdugGP9sTBasSLaF721Giks
nmHkopLr696hCtKSez5YwZCuDaPehUUHtQ96UeM70WQnascTUwTtJ8FMz3tKSe6hxbB1-
nVhS7qyRArNmNcFGNW6sg2YHVMHHqodOkZEmvAFZiUGNzxRvkkpk7mNdb9kKtHBhlrBQ9
nAPZIYk7TL989aT-bQG400t9XA2oZCHzCqeCJ7wsZ8kkNJ-ERM7-BiPeGYWhS4RhtJDwu
n2fNeqh8KVKJQL7sJJylH7sOKp4g6aLIeLMv1naedDxdu2lyGSIVB7kKTmZG1UUwWigwC
n0SdAqr4vQPCLWZ7a0aAwB+oZDu9Ufk3MApvmYrnEVodMMDuwTaD8ADvEsLfGSz090Bkl
nAZMm4aZhWFemnF1ujtN7BbC5jzuAtX4XouFU+Z7ThXTubaUzA4X2jQzmUYomouAXvVlR
nB2uGGmcY51CMl78EifoIS-WTkFzrGwzZTT7GzKDyqDUzEKZDBlbpNs24Sp79SaHtwuip
nzdK60p7ATmZY6DqL2Z6luHjTo5M9JslCsfJdagZG90JgDE0m-LfYcA2D4lqOzMrPErkY
nroC6JMlQLrFQygbsmeoAkRYleLciw8oWjfCzQDRXWnomcHzeFxtJk2wu-9Vq39W2Dhs8
njAnMjRSzmXmg0bQ4Ohf1jon0GOp-G3DM-ARkD65ihONqHcZLlPlNSWtuIaAZLvlxIxs6
n0ZqzEzTifzKOr2Qi8ci3-b5dEP9t-Ygx-XyCO0J-qyWSuX7GUal8byJ4UiMp5m7JD566
nk1M7TM2slCv6P6gnPmfqRdjv-BL1GCWJ-wqKg-6U+fQ9NrIWUswvu7Jn0xNpApOZ4jDB
n8dXDOIsr+4CCxvCTUgmyGfnmN1pZgITybc3daPaIAYyv0+pqnTk4ZjSJ+C+RigNKWXMb
n2vP9f4pIYxHs5uU+CTdfJmN2l6IPDsZyVnelPGJVp8YC5P7cE1euNag7HCLWW83fUYdY
nI-++K++cI30GYQYagiUN+JyGpk+YyHIrQJ3+5LF+1lv-lE-l4LmS+w74Z6lljb288kml
n910VsYi31HwjQH-OUpc2q5u8EHWUf4Gk8sWPwKJpd5QF1IsL1IaQjqoFM7BiYdOFX+D4
n+2A+8QT74ST6JCjgYttDhM3nGzQbkO6rUgqJHseQhkC0+ETe1zcg5UiBCpg8PaANQ4Qy
n+82Fuwb5McdE-6x2Xds8ED1juY3cyV5WXVJ9ffGs0k1pl5caghzDbaqH4hPW4QEI2236
nynwrigmMiK3jBs7xv4AXvBWTuA91PET4IHl8fH-s5B1H0osv-hQGEi8W4OI5HdtvzDG8
nWMATA+VrvQO2vdTxwnxVfoDY71JW9p9XJm2-i67jy330yY++wL0D4dAy05-KQWCMCPyb
n8WmCoStmUZ5cw7wArJuKy5yYGlBN+zzg1vT-GlImYtmSQqA+KuLbEHmGXMAus56zD3km
n8WScICYcIwcIZUdD-Lp2CSG37qHgXS2AbFjQ2cZXql7ZEfQVAaxdr+OtuGaneDyrVqFL
npkLQHsZc46CuK0UjKdp1aDvBWcgHSzNP9Q76Ovv50ira6L4aLcD7u+QXSw-vl6bOowHD
n-ccdsXTLh8Ga1mp2sfur3dXDFPPVN5Net4cHrt6KeLYZ3yO3Pw8tesj1Px2rPhdy16JL
nhL7L7uO4UaK7e9oEhuHJUUiZF9xX5A0Wgx7UYGAPDiWeUAdvTXNSV09-xfqmPwoUSjiu
ntChmZy4BVOZPP5ZLak2+1Y4aNu9zN-voxcJWBWuwdrjZ4owfdZbqGj62tXiVkMh6kMHh
n4a1PxUb3xrIiqQmYwV2kYNEYbmyFWDeBsWZ54wcu7BTSthHjNtJpx9wYBH98JXINckfo
nR+0+8E+-+k++wEM+++0dlo-f++X-6+wp0E+U++++IoJIFIkiF2x1ypC-gh3TQ-Kf4YUG
nS-zyizbdpyT95ysEvGodKEKRDu5H-PhT9UhS3XrwfjdD5ZUhMNxoAm-cC1qCo056VgcT
nvta42txHufGBEM9eZCMenhOOeIrocLAmtz32CNknY6I2k-Jr2mNOzHHe7PVaswQW73mF
n0wHH8M9Y0kO8xke+JaVZcCYx8JK2Tqh5RXRG-Qd6JADFv3zjt1Oduya5NwipNTRow0d2
nYArf9-FClVw4oMMRpsP4XfxXoKJsTtPy2VX-Nk5DhgQXOwj3Tf50flINmKwJuhl+Rjlf
nSu3+rsrMrilJ343dkNti4GJ6jSdYIhkkjsEuzMbkW317BeHi7UHbhWJh4jbapp4T1qKA
nNAqzGAxB-k8Iflq0cexT+bQfkZ0JkSHnBYifP6F0Ke2N7NIAWizjNBz6HKag2BMYJAsL
nssiWKOBszD6lZdPdMOmCQg2xC6Le1nRzBOVBvLwirpjN0BQ9YJydwAaNOfkUyoekFf+D
neJozr0C1QXZoUn1t4v1dvmZmq4bUlCK2YKJ1YHboNYfoaDwqxgRz7w0Pyv5A3EWYcI1g
nOXHtTwqOkWWbKt+CZTMaJ3pd0JaEBidgwNhNq36arpXSpOtJGq-VBDESBfZnnVhz6iKB
noXDJIvVstLrSW90cJMZ2vakN8kQVxlG+v56VhiFySKpzAhHuEEWSqIXEMpbDy0BR14ai
nkSJ41ziB407iDF09Tp82S8tM3PXRBQtXAN3ao38S7OeqGBYm2VytEO-VdpHmYO+kT6Kh
nk0HqT87+WCpgvJrp5kujxj4qKp8jYZV8ReWuHzywL28pRdz+hMetJhuQd5c5BHJ4dnC-
nQt33QJ2er0OslY+I6qGmyUAfIfwpqz8wQPblP3keYW6Ut9Z1Eb1gkYe5pFY4F-q-JbCs
nVUgE-78bzXu8lXqqpoqmrrKmkEx-Bcih25tlet-Az071TjWP8jup2VLJfQUOp9BtJWnn
fnwIm490FtnOJ5a4Wm1ntMAZQ639+ifRIOatIXlWwRP7Q6EFsq7vNMZFanQUO
*XXBUG Version 2.21 by Chad Wagner
----------------------------> CUT HERE <-----------------------------
If you have downloaded this script file, remove any captured
communications header and then enter
DEBUG < filename
where filename is the name of this script file.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 05 Jun 96 14:05:42
From: Vernon Frazee Read: Yes Replied: No
To: Larry Nelson Mark:
Subj: Errorlevel.exe
──────────────────────────────────────────────────────────────────────────────
Summary:
MAKEL BAT 894 06-01-96 1:00a When launched with a number
between 0 and 255 (inclusive)
on the command line, MAKEL.BAT
will create a matching 6-byte
filename with a COM extension.
When this COM file is
subsequently executed it
places the corresponding
errorlevel in memory.
MAKALLEL BAS 627 06-01-96 1:00a Creates all 256 6-byte .COM
files, 0.COM thru 255.COM.
When each of these COM files
are executed they place the
errorlevel indicated by their
filenames in memory. (e.g.
96.COM sets errorlevel 96).
ALLELCOM SCR 6,084 06-01-96 1:00a ALLELCOM.SCR contains
ALLELCOM.ZIP which
contains ALLELCOM.RAR
which contains all 256
6-byte COM files (0-255.COM).
SETEL SCR 8,967 06-01-96 1:00a Contains SETEL.RAR which
contains SETEL.COM and
SETEL.DOC. SETEL.COM is
actually a XEQ.COM (v1.15 COM
File Library and Command
Executor) which contains all
256 6-byte COM files. (Saves
room on the hard drive). Each
of these, when executed right
from within SETEL.COM, will
place the errorlevel indicated
by their filename into memory.
For example, use the command
SETEL 96 to place errorlevel
96 in memory.
Syntax: [d:][\path\]SETEL #
(Where # is any number between
0 and 255 (inclusive)).
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 10 Jun 96 20:23:00
From: Ron Warder Read: Yes Replied: No
To: Axel Merkel Mark:
Subj: arj & delete
──────────────────────────────────────────────────────────────────────────────
> i'm looking for a batch that will do something like this
> checking one directory like arj t *.arj, and if happends a CRC failure,
> deleting this file
A good start would be to familiarize yourself with ARJ's different exit codes
(also called errorlevels):
----------------------------------------------------------------------------
(From ARJ 2.41a docs)
ARJ DOS ERRORLEVELS:
ARJ returns a number of DOS errorlevels for different situations.
0 -> success
1 -> warning (specified file to add to archive not found,
specified file to list, extract, etc., not found,
or answering negatively to "OK to proceed to next
volume..." prompt)
2 -> fatal error
3 -> CRC error (header or file CRC error)
4 -> ARJ-SECURITY error or attempt to update an ARJ-SECURED archive
5 -> disk full or write error
6 -> can't open archive or file
7 -> simple user error (bad parameters)
8 -> not enough memory
9 -> not an ARJ archive
____________________________________________________________________________
So, to trap a CRC error in a tested ARJ file, for example, you would need to
test for errorlevel 3. Note that errorlevel tests need to be performed in
REVERSE order to work properly.
As far as the structure of the BATch, I myself wouldn't -delete- the file,
since ARJ has some built-in repair capabilities. I would, however, MOVE it to a
holding area for further processing/repair efforts. But, hey, you wanna delete
it, no problem!
Pull the text below into your favorite ASCII editor, and save the two batch
files shown below as ARJTEST.BAT and CHK_ARJ.BAT, respectively. Remember to
join the two lines in CHK_ARJ.BAT where indicated, otherwise, that part won't
work as designed.
::ARJTEST.BAT --------------------------------------------------------- @echo
off
for %%a in (*.arj) do call CHK_ARJ.BAT %%a
:end of ARJTEST.BAT ---------------------------------------------------
::CHK_ARJ.BAT --------------------------------------------------------- @echo
off
cls
echo Now testing %1.'s integrity, please stand by ....
arj t %1 >nul
if errorlevel 9 goto ERR9
if errorlevel 8 goto ERR8
if errorlevel 7 goto ERR7
if errorlevel 6 goto ERR6
if errorlevel 5 goto ERR5
if errorlevel 4 goto ERR4
if errorlevel 3 goto ERR3
if errorlevel 2 goto ERR2
if errorlevel 1 goto ERR1
goto OK
:ERR9
echo File %1 is NOT a valid ARJ file!
echo File %1 is not a valid ARJ file. Please check this file.>>arjtest.log
goto end
:ERR8
echo Not enough memory to complete operation!
goto end
:ERR7
echo Invalid Parameters. Please check commandline!
goto end
:ERR6
echo Unable to open %1! Check spelling and make sure file exists.
goto end
:ERR5
echo Disk is either full or write protected.
goto end
:ERR4
echo ARJ-SECURITY error or attempt to update an ARJ-SECURED archive
goto end
:ERR3
echo CRC error! %1 is probably corrupt.
del %1
echo File %1 had a CRC error and has been deleted.>>arjtest.log
goto end
:ERR2
echo Fatal error! Process aborting.
:: Next two lines should be 1 line. Remove "..." from end of next line
:: and beginning of following line and rejoin lines before running batch!
echo File %1 caused a fatal ARJ error. ARJ header most likely ... ...
corrupt.>>arjtest.log
goto end
:ERR1
echo Warning! Specified file not found,
goto end
:OK
echo Process was successful, no errors found.
echo File %1 checks out OK!>>arjtest.log
:END of CHK_ARJ.BAT ---------------------------------------------------
Hope this helps. Let us know how it works for you....
-!- SLMAIL v4.0a (#0304)
! Origin: Free Spirit =*= SL/RIP =*= 301-283-0917 =*= V32b/HST (1:109/132)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 427 Date: 12 Jun 96 18:09:52
From: Vernon Frazee Read: Yes Replied: No
To: Andrew Adams Mark:
Subj: Batch Help
──────────────────────────────────────────────────────────────────────────────
AA> Is there any way I can use a batch command to retrieve a line out of
AA> a file? For example, say I wanted to retrieve the 3rd line of
AA> README.TXT. What would I do? Or can you even do this with Batch?
If you don't mind the line number surrounded by square brackets
preceding the text of the line itself, it can be done right from
the DOS prompt. For example, let's say I wanted to see line "3"
of a file named FILENAME.TXT:
Yo, DOS FIND.EXE,
| number each line
| | as you DON'T look for
| | | this weird string
| | | | in this file.
| | | | |
| | | | |
| | | | | Wait, you're not done;
| | | | | | now look for this.
___| _| _| __________| ___________| ___| __|
find /n /v "_!@#$%^&*()" FILENAME.TXT|find "[3]"
If the 3rd line in FILENAME.TXT was:
We the People of the United States, in order to form a more
the above command would display:
[3] We the People of the United States, in order to form a more
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 428 Date: 12 Jun 96 18:02:44
From: Vernon Frazee Read: Yes Replied: No
To: MIKE DUTTERA Mark:
Subj: COMMAND.COM
──────────────────────────────────────────────────────────────────────────────
MD> If one works mainly in DOS, then I can see the wisdom of a ram drive
MD> to store frequently used bat files etc., but command.com? Why? isn't
MD> it already in conventional and upper/high memory RAM after boot-up?
When COMMAND.COM is on a RAMDRIVE and the COMSPEC environment is
variable pointing to it, it can reload its transient portion much
quicker than it can from a hard drive.
COMMAND.COM divides itself into two pieces when it is first loaded
into memory. The "resident" part, about 3K or so bytes, sits in the
lower end of memory above the the other two DOS files (IO.SYS and
MSDOS.SYS). The "transient" portion -- the bulk of the program --
resides up at the very top of user memory.
The transient part interprets and executes the DOS internal commands
and does BATch file processing. These facilities are not needed
when other programs are running. By sitting at the top of memory,
the transient portion does not take up valuable memory space. It
can be overwritten by other programs if they need the space.
When a program exits, it return control to the resident part of
COMMAND.COM, which performs a simple checksum calculation of the
memory area normally occupied by the transient portion. This way it
can tell whether the information loaded in that area of memory is
indeed its own transient part or whether the transient part was
overwritten. If it was overwritten, the resident part looks to the
COMSPEC environment variable for COMMAND.COM's location and then
reloads the transient portion of itself back into memory.
That's why exiting from a large program can cause a disk access when
COMMAND.COM is reloaded into memory. Some programs -- like Lotus
1-2-3 and many compilers -- always use that top memory area, so this
can happen frequently.
(Note: 98% of the above was taken from the old original but still
good "PC Magazine DOS Power Tools, Techniques, Tricks and
Utilities" by Paul Somerson).
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 434 Date: 14 Jun 96 11:26:00
From: Roy Reed Read: Yes Replied: No
To: Ingrid Dekker Mark:
Subj: every third time
──────────────────────────────────────────────────────────────────────────────
*ZV{Ingrid-
Here is a jobbie that will do the stuff every third time, but
I'm not using numbers to count with, seeing it's only three counts.
Just run this and follow the echoes. This could easily be expanded,
but maybe you want to use numbers 1, 2 and 3. I'm not sure.
Oh well, going for the early input.
CYAH.
Roy
------------------------------------------------------------------
::doafter3.bat
@ECHO OFF
IF EXIST C:\FIRSTONE GOTO TWOTOGO
ECHO FIRSTONE>C:\FIRSTONE
ECHO TWO MORE TIMES TO GO BEFORE IT GETS DONE!
GOTO END
:TWOTOGO
IF EXIST C:\SECOND1 GOTO ONETOGO
ECHO SECOND1>C:\SECOND1
ECHO NEXT TIME IT GETS DONE!
GOTO END
:ONETOGO
FOR %%X IN (FIRSTONE SECOND1) DO DEL C:\%%X>NUL
ECHO GOING TO DO THE THINGS NOW
ECHO PUT YOUR STUFF TO DO HERE
:END
-------------------------------------------------------------------
I named it doafter3.bat, but not critical - run the stuff between
the lines.
! Origin: The GIFfer BBS, 75+gig, (813)969-2761 (1:377/50)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 432 Date: 14 Jun 96 06:12:12
From: Vernon Frazee Read: Yes Replied: No
To: DAVID BATTESTELLA Mark:
Subj: Batch command 4 "RETURN"
──────────────────────────────────────────────────────────────────────────────
DB> In writing a batch file what command or combination of characters
DB> would I use to emulate/simulate hitting the "RETURN" key?
You might try something like:
VER|name_of_program
or:
echo.>~tmp
name_of_program<~.tmp
del ~tmp
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 18 Jun 96 12:11:17
From: Vernon Frazee Read: Yes Replied: No
To: Ingrid Dekker Mark:
Subj: EVERY3RD(time).BAT
──────────────────────────────────────────────────────────────────────────────
Hello Ingrid,
Bat just informed me that I messed up again. ;( The EXAMPLE.BAT I
recently sent to you executed something 3 times instead of executing
something every 3rd time. Sorry for the confusion. The following
attempt appears to be working here with nary a hitch.
@echo off
:EVERY3RD.BAT ----------------------------------------
if (%1)==() goto Begin
if (%1)==(/1) goto Begin
:Syntax ----------------------------------------------
cls
echo.
echo Name: EVERY3RD.BAT
echo.
echo Purpose: Run what is under label ":RunIt" only
echo every 3rd time this BATch is launched.
echo.
echo Syntax: EVERY3RD [/?][/1]
echo.
echo Where: The /? option displays this brief help
echo or: the /1 option resets the count to 1.
echo.
echo Requires: DOS's FIND (somewhere in the PATH) and
echo 20 bytes free environment space.
echo.
echo Notes: This BATch file is self-modifying!
echo It keeps track of the number of times
echo run at the end of itself. Hence, all
echo 4 occurrences of "C:\BAT" below MUST
echo be changed to the location where you
echo store this BATch file.
echo.
echo Do NOT use the ".BAT" extension when
echo launching this BATch file.
echo.
goto End
:Begin -----------------------------------------------
for %%x in (:) do set ~colons~=%%x%%x!
if (%1)==(/1) goto Reset
find /c "%~colons~%" C:\BAT\%0.BAT>~tmp~.bat
echo set ~tmp~=%%2>--------.bat
for %%x in (call del) do %%x ~tmp~.bat
del --------.bat
--> if not (%~tmp~%)==(3) goto AddOne
:RunIt -----------------------------------------------
echo This is the area where you insert the
echo sequence of commands you want to run
echo every 3rd time this BAT is launched.
:Reset -----------------------------------------------
type C:\BAT\%0.BAT|find /v "%~colons~%">C:\BAT\%0.BAT
:AddOne ----------------------------------------------
echo %~colons~%>>C:\BAT\%0.BAT
:Cleanup ---------------------------------------------
for %%x in (colons tmp) do set ~%%x~=
:End (Data storage begins below) --------------- -vjf-
::!
You can change the number "3" in the line marked with the "-->"
to whatever number suits your needs.
EVERY3RD.BAT was designed as self-modifying BATch file simply to
save room on the hard drive. (No extra files).
Let me know if this is still not quite what you had in mind.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batpower ─────────────────────────────────────────────────────────────
Msg#: 82 Date: 23 Jun 96 01:12:00
From: Mike Zeleski Read: Yes Replied: No
To: Andrew Adams Mark:
Subj: Setcursor
──────────────────────────────────────────────────────────────────────────────
AA>Hello!
AA>I need some kind of utilitie that can set my cursor in a specific
AA>row/column that I can distribute freely with a batch program...
Before I tell you this, I would like it clear that I'm not trying to
make you go duhhh...
However there is an utility that ships with every copy of Dos that can
do this. "ANSI.SYS"
But of course you have to have it loaded for the ansi escape sequence to
work. A friend of mine used such ansi code in a batch program to
simulate a flag waving in the wind. So @echo'ed ansi sequences can get
quite elaborate...
In this case I'm going to use * = [Esc] here as I don't know how it
would come through here.
To create the Esc in Dos Edit, hit [ctrl] + P, then hit [Esc], you will
then see the backwards pointing arrow that is the Esc character. It is
also the standard ASCII letter 27, so some editors may be able to create
it by hitting [alt] + 27...
Examples
echo*[5,10H
echo*[5,10f
Both should move the cursor to row 5 column 10.
echo*[3A
This should move the Cursor up 3 rows.
echo*[3B
This should move the Cursor down 3 rows.
echo*[8D
This should move the Cursor left 8 spaces.
echo*[s
Saves current cursor location.
echo*[u
Return to saved location.
echo*[2J
Clears screen and moves cursor to the home position. (aka 1,1)
-!-
* OLXWin 1.00b * I'm Warped, I know, How can you Warp something so twisted?
-!- WILDMAIL!/WC v4.12
! Origin: Father & Son*610-439-1509*Whitehall Pa (1:2607/112.0)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 25 Jun 96 23:40:00
From: David Mohorn Read: Yes Replied: No
To: Brett Todd Mark:
Subj: Upcasing %1, etc. inputs
──────────────────────────────────────────────────────────────────────────────
BT>@PID: TerMail 4 EVALUATION
>@MSGID: 2:251/31.2 cca89588
>Hi there All,
BT>Could someone please tell me how to upcase a %1 or %2, etc. input to a batch
>file, so if %1 was "brett", it would be displayed as "BRETT".
How about:
SET OLDPATH=%PATH%
SET PATH=%1
SET NAME=%PATH%
SET PATH=%OLDPATH%
SET OLDPATH=
ECHO Hello, %NAME%
RIME: ->1369 FIDO: (1:275/102) INTERNET: david.mohorn@sourcebbs.com
-!-
■ QMPro 1.53 ■ I smoked Marijuana but didn't exhale and still haven't.
! Origin: (1:275/102)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 30 Jun 96 12:21:00
From: Horst Schaeffer Read: Yes Replied: No
To: Roy Reed Mark:
Subj: multiple commands on dir files
──────────────────────────────────────────────────────────────────────────────
-=> quoting Roy Reed to Carlos Legaspi (25 Jun 96) <=-
RR> [...]
RR> Each file in turn gets called as a parameter (%%x becomes %2)
RR> and gets passed to :carlos for processing (called recursion).
RR> --------------------------------------
RR> if "%1"=="carlos" goto carlos
RR> for %%x in (*.*) do call %0 carlos %%x
RR> goto end
RR> :carlos
RR> [commands with %2]
RR> :end
RR> --------------------------------------
How about this one:
%2 for %%x in (*.*) do call %0 %%x REM
%2 goto end
[commands with %1]
:end
Horst.
... Q4FM 2.10a ... horst@confusion.rmc.de
-!- FM 2.02
! Origin: Don't follow leaders! (2:2480/13.75)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 423 Date: 29 Jun 96 11:11:30
From: Horst Ehm Read: Yes Replied: No
To: Andrew Kennedy Mark:
Subj: saving prompt
──────────────────────────────────────────────────────────────────────────────
Hallo Andrew!
Antwort auf eine Message von Andrew Kennedy an All:
AK> CAn someone show me how I can save my prompt setting in a variable so
AK> I can restore it later after it has been changed. Thanks
Your settings are already saved in the e-var PROMPT.
You can write the contents of PROMPT to another e-var and vice versa as shown
below.
@set old_prmt=%prompt%
@prompt DOS = $v$_Time = $t
@echo off
prompt %old_prmt%
set old_prmt=
Horst
-!-
! Origin: Multitasking -> Auf dem Klo lesen ! (2:241/225)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 430 Date: 08 Jul 96 13:02:36
From: Andy Guess Read: Yes Replied: No
To: Mike Stewart Mark:
Subj: Dates
──────────────────────────────────────────────────────────────────────────────
MS> Im wondering how to go about having a batch file that will
MS> change the computer's date to a specified date(by me), before
MS> running a program, and then changing it back to the origional date
MS> upon exiting the program.
Save this as DATEBACK.BAT.
+=+=+=+=+=+=+=+=+==+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
@echo off
ver|date>date!!!!.bat
echo set date=%%4>current.bat
call date!!!!
date %1
rem Your program here
date %date%
set date=
for %%f in (date!!!! current) do del %%f.bat
+=+=+=+=+=+=+=+=+==+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
Edit the file so it runs whatever program you like (line 6). If you type
DATEBACK 1-1-99
then the date will be set to 1-1-99, then the program will be run, then the
date will be restored. You'll lose a few seconds while the program runs, of
course. If run without any parameters, it will prompt you for a date.
Hope this works for you.
{Write Back!} [/^\ndy Guess]
.!. Shut up, Spock! We're rescuing you! --McCoy
-!- Terminate 4.00
! Origin: -AG {andy.guess@myplace.blkcat.com} (1:109/570.15)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 10 Jul 96 15:06:32
From: Vernon Frazee Read: Yes Replied: No
To: Roland Ribi Mark:
Subj: Put the date in a textfile
──────────────────────────────────────────────────────────────────────────────
RR> Does anyone know how I can put the actual date with a type command
RR> or however into a Text file? Thanks for the information!
@echo off
:GETDATE.BAT
:Puts the current system date
:in a file named GETDATE.DAT.
ver|date>~.bat
echo set date=%%4>current.bat
for %%x in (call del) do %%x ~.bat
del current.bat
echo %date%
echo %date%>GETDATE.DAT
set date=
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 450 Local Date: 16 Jul 96 13:56:05
From: Bat Lang Read: Yes Replied: No
To: All Mark:
Subj: Batch Book
──────────────────────────────────────────────────────────────────────────────
From time to time we get asked to recommend a good book on batch files.
For that reason it is a topic covered in our BAT-FAQ1.ZIP, recently
hatched into the BFDS FDN, and avail at our BFDS sites and FTP site (see
'Echo rules', elsewhere in this pkt). That topic in the FAQ looks like:
THE BATPOWER FAQ,
or Frequently Asked Questions
| *** Last revision: 28 Jun 96 ***
[... text deleted for brevity ...]
26. BATCH PROGRAMMING BOOKS
~~~~~~~~~~~~~~~~~~~~~~~
While the following books have been recommended by various echo
users, any choice should always be based on your personal
examination of the book, to ensure that it meets your needs.
DOS Power Tools by Paul Somerson
Supercharging MS-DOS by Van Wolverton
MS-DOS Batch File Programming by Ronny Richardson
Advanced MS-DOS Batch File Programming by Dan Gookin
Concise Guide to MS-DOS Batch Files by Kris Jamsa
---------------< cut here >-
The first four are 'original inhabitants' in the FAQ and, no matter what
else their merits, they are dated. Which brings me to the last one,
added by me after a recommendation here by Greg Miskelly, our Irish
bard (author of GMUTILS3.ZIP {BFDS} which contains PSIS, a dandy batch
enhancer). At the time, I snipped his msg to a note file, as:
> As far as books are concerned, the best book I have encountered for
> starting off with is:
>
> Concise Guide to MS-DOS Batch Files
> by Kris Jamsa
> Microsoft Press
> for Beginning, Intermediate and Reference
> ISBN 1-55615-638-3
> USA $12.95
>
> It's good points are:
>
> It's affordable.
> It does _not_ have a diskette full of already prepared batch
> files whereby you don't learn anything.
> It is really very well put together.
> The author is a DOS _expert_; I have other books by him that
---------------< cut here >-
Ever since he posted these words (27 Aug 95) I have tried to find a cy
of this book. In April I intensified the search, special ordering it
from two specialty book stores. I never heard back from either of them,
after several followups. I finally FAXed the publisher, and got back a
form letter with an 800 number? This only led to a referral to the
publishers 800 #. To make a long story short (finally), after about ten
more phone calls, I located a single cy in our local Software ETC. which
handles mostly software, some hardware and books.
Now that I have had a chance to look it over, I can add an enthusiastic
endorsement to what Greg had to say above. The publisher indicates it
went out of print about the time of Greg's posting, last summer. The
reason that I am telling you all of this is that you will need to strike
while the iron is not stone cold, if you are to find a cy. The
International distribution is listed as:
In Canada, by Macmillan of Canada
In USA by, the publisher, Microsoft Press
In the rest of the world, by Penguin Books Ltd.
Penguin Books Ltd, Harmondsworth, Middlesex, England
Penguin Books Australia Ltd, Ringwood, Victoria, Australia
Penguin Books N.Z. Ltd, 182-190 Wairau Road, Auckland 10, N.Z.
Newbies to batch, in particular, are recommended to seek out a cy.
BTW, it covers MS-DOS versions as recent as 6.2, and is (C)1994.
Good Modeming! /\oo/\
... NetMail: 1:382/1201 or E-mail: bat.lang@1201.ima.infomail.com
-!- Blue Wave/Max v2.30
! Origin: The HUB * Austin TX * Centex PCUG * 512-346-1852 (1:382/1201)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 15 Jul 96 05:28:01
From: Vernon Frazee Read: Yes Replied: No
To: Russ Army Mark:
Subj: %'s
──────────────────────────────────────────────────────────────────────────────
RA> WHen I was ritin dirzip thingy I had a question.
RA> I know %1 is the first werd after the command
RA> %2 is the second
RA> etc etc
RA> Is %f stand for file
RA> %w ???
RA> others?
RA> I would be helped greatly if I could know this
In the following for-in-do command:
for %x in (Russ Army) do echo %x
the "%x" is simply the name of a variable. The "x" in "%x" can be
durn near any character you want. If you type "HELP FOR" (not the
quotes) and look under <Notes>, Microsoft states "To avoid confusion
with the batch parameters %0 through %9, you can use any character
for variable except the numerals 0 through 9." ~~~
That's almost right. There are 8 characters that will not work:
Decimal Character
------- ---------
37 %
44 ,
47 /
59 ;
60 <
61 =
62 >
124 |
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-!- Terminate 4.00/Pro
! Origin: Terminate point system (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 441 Date: 19 Jul 96 09:47:00
From: Benjamin Ng Read: Yes Replied: No
To: Andrew Adams Mark:
Subj: Commenting ZIP files....
──────────────────────────────────────────────────────────────────────────────
Greetings Andrew!
07-17-96 (22:48), Andrew Adams wrote to All about Commenting ZIP files....:
AA> Does anyone know how I can make a batch file to add comments
AA> to ALL the zip files in 1 directory???????
Try this 1-liner:
@for %%x in (.\*.ZIP) do pkzip.exe -z %%x < zcomment.txt
It will use the current directory unless you substitute with your
own path (yourpath\*.ZIP). Use a full pathname for the zcomment.txt
file if applicable.
Regards,
Ben.
-!- Maximus 2.02
! Origin: EXCESS - CALGARY ALBERTA CANADA (403)285-7338 (1:134/17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 24 Jun 96 03:12:10
From: GARY SMITH Read: Yes Replied: No
To: ROY REED Mark:
Subj: for-in-do goto
──────────────────────────────────────────────────────────────────────────────
RR> This was in the batpwr01.zip. Can anybody do some splainin
> why it doesn't (?apparently?) got to labels 1 and 2?
> --------------------------------------
> @echo off
> for %%n in (1 2 3) do goto %%n
> echo Fell through!
> goto end
> :1
> echo Hit label 1
> goto end
> :2
> echo Hit label 2
> goto end
> :3
> echo Hit label 3
> : end
The combination of FOR/IN/DO with GOTO is extremely peculiar.
When COMMAND.COM executes a GOTO, it stores the label, opens the
batch file, and reads lines from the beginning until it locates
the label or exhausts the file. It has only one place to store
the target label, and thus will remember only the last label it
saw. When you combine a FOR with an unconditional GOTO, the
transfer will always be to the last label. When the the GOTO is
conditional, the transfer will be to the last label for which
the condition is true.
-!-
■ OLX 1.53 ■ All we are saying is, "Give pizza chants."
! Origin: The Inner Circle, Pickerington, Oh (614)861-8377 (1:226/110)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 24 Jun 96 03:12:10
From: GARY SMITH Read: Yes Replied: No
To: MARC GRIFFIN Mark:
Subj: full delete...
──────────────────────────────────────────────────────────────────────────────
MG> WS> find to associate with it. Hence, using Norton Unerase (or was it
> WS> Undelete) with the Manual option on, it only takes a minute to recover
> WS> a file which has been deleted, then recreated and deleted again. I
> WS> think this kind of explains my reasons for posting. Besides, anyone
> WS> else reading this who didn't already know, is now aware of how to eras
> WS> and over- write a file from Batch :-)
> I've only just joined this area... Wouldn't it be okay to just copy a file
> OVER the file you are trying to delete?
Not if you use the COPY command. COMMAND.COM's COPY function
does not overwrite the clusters which currently belong to the
file. The data is written into newly-allocated clusters and the
old ones are freed. Since recent versions of DOS postpone the
re-allocation of freed clusters as long as possible, the original
data will most likely hang around for quite a while. I've just
tested this under DOS 6.22 and was able to recover the original
data in a few seconds with Norton DiskEdit (version 4.5, I think).
Vernon's QBASIC solution ought to work, though, since it must
necessarily write to the original clusters.
-!-
■ OLX 1.53 ■ IneedsignificantlymoreroominthislineforwhatI*really*want.
! Origin: The Inner Circle, Pickerington, Oh (614)861-8377 (1:226/110)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 442 Date: 24 Jul 96 17:21:00
From: Mike Zeleski Read: Yes Replied: No
To: Dave Fleming Mark:
Subj: Compiled .BAT?
──────────────────────────────────────────────────────────────────────────────
DF>Gidday again,
DF> I heard somewhere that there is such a thing as BAT2COM or BAT2EXE or
DF>something that will convert a batch file into an executable program. Is
DF>this even within the realm of reality?
There were several "Batch Compilers" that were written over the years.
DF> I assume it could be done, but the compiler would have to do a LOT of
DF>searching to include programs that are elsewhere on the disk! <g>
Nope; it just has to shell into the external program like any other
programing language can. Just don't move that program out of the path or
you may "break" your compiled code...
DF>I also assume someone is pulling my leg, how efficient could something
DF>like this be?
Actually if the program was optimized to allow Nulls and Redirection to
remain in memory, and optimize many of BFP's slower instructions, the
compiled version often can be remarkably faster with large Bats...
Look for a book Titled Builder Lite; Developing Dynamic Batch Files.
(With Program Disk.) By Ronny Richardson, Windcrest/McGraw-Hill, 1993.
Summary: Programming Language Reference with Editor and Compiler.
(May be out of print now, but you may be able to find it second hand.)
Builder & Builder Lite should be available from:
Hyperkinetix, Inc.
18001 Irvine Blvd, Suite H
Tustin, CA 92680
-!-
* OLXWin 1.00b * Espresso: An Ultra Efficient caffeine delivery system.
-!- WILDMAIL!/WC v4.12
! Origin: Father & Son*610-439-1509*Whitehall Pa (1:2607/112.0)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 388 Date: 25 Jul 96 16:28:58
From: Vernon Frazee Read: Yes Replied: No
To: Cameron Clark Mark:
Subj: directories & loops[q]
──────────────────────────────────────────────────────────────────────────────
25-Jul-1996 16:28
Hello Cameron,
On 21-Jul-96 at 17:47:26, "All" and "Cameron Clark" were discussing
"directories & loops[q]":
CC> Is there any way to loop thru the directory names as well as file
CC> names? I notice that on the following scenerio that directories are
CC> exempt from the listing: [assume there are several directories named
CC> folder??]
CC> for %%c in (folder??.*) do (some list of instructions)
CC> It there a way to iterate thru directories? Also, is it possible to
CC> have the loop iterate executing a list of instuctions each time?
Place the following SWEEP.BAT in a directory that is in your PATH:
@echo off
:SWEEP.BAT - Original from PC Computing
if not (%1)==() goto Begin
:Syntax -----------------------------------------------------
echo Name: SWEEP.BAT
echo Purpose: Execute specified command in every directory
echo Syntax: SWEEP command [parameters]
goto End
:Begin ------------------------------------------------------
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
set SWEEP=%1 %2 %3 %4 %5 %6 %7 %8 %9
cls
echo Creating a list of all directories on current drive ...
echo @prompt set CurrentDIR=$p>tmptmp.bat
command /e:2048 /c tmptmp.bat>director.bat
del tmptmp.bat | call director.bat
echo @echo off>director.bat
echo prompt $g$h>>director.bat
echo cd %%1>>director.bat
echo %%SWEEP%%>>director.bat
echo cd %%CurrentDIR%%>>director.bat
chkdsk/v|find "Directory"|find "%CurrentDIR%">tmptmp.lst
echo exit>>tmptmp.lst
command<tmptmp.lst
echo Processing complete.
:Cleanup ----------------------------------------------------
for %%x in (tmptmp.lst director.bat) do if exist %%x del %%x
for %%x in (CurrentDIR SWEEP) do set %%x=
:End --------------------------------------------------------
To give you an example of what it can do, the following command will
delete all "*.BAK" files in every directory on drive C:.
sweep del *.bak
Note: Since SWEEP.BAT starts with your current directory and then
proceeds through every subdirectory under it, to get it to go
through every subdirectory on drive C:, the above command
would have to be issued from the root directory of drive C:.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Rec'd Date: 30 Jul 96 17:08:00
From: Jim Talbot Read: Yes Replied: No
To: Kent Anderson Mark:
Subj: directories & loops[q]
──────────────────────────────────────────────────────────────────────────────
KA>SWEEP.COM, by Charles Petzold, is also in PC Mag utilities, volume 1.
KA>I use it from time to time to move all archived files into one
KA>directory, to delete BAK and TMP files, etc. A very handy utility to
KA>have, even though it dates back to 1986.
Another use for that handy little SWEEP.COM is in conjunction with
Undelete. I wrote a simple little bat to call up SWEEP AND UNDELETE. The
command SWPUNDEL now causes UNDELETE to scan each dir and subdir in
turn. This can be handy if you accidentally delete something and it
doesn't show up in the undelete list of the directory from which you
think it disappeared. This has saved my bacon.exe a few times. It is
simply amazing how those deleted files manage to hide in the most
unlikely places.
* SLMR 2.1a * Coles' Law: Thinly Sliced Cabbage.
-!- TriToss (tm) Professional 10.0 - #225
! Origin: The OutDoor Experience 902-461-4713 (1:251/32.0)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 442 Date: 08 Aug 96 08:15:08
From: Vernon Frazee Read: Yes Replied: No
To: Rob Oosten Mark:
Subj: Fc or comp return errorlevels?
──────────────────────────────────────────────────────────────────────────────
8-Aug-1996 08:15
Hello Rob,
On 23-Jul-96 at 16:17:03, "Vernon Frazee" and "Rob Oosten" were
discussing "Fc or comp return errorlevels?":
AK> Does either fc or comp return errorlevels, and if so what are they
AK> for files which do NOT match.
VF> Unfortunately no, not in any of the MS-DOS versions just tried here.
RO> But there's a way around it, at least for FC. FIND does have
RO> errorlevels!
RO> @echo off
RO> del differ
RO> fc %1 %2>>differ
RO> type differ|find "*****"
RO> echo.
RO> if errorlevel 2 echo Something went wrong!!
RO> if errorlevel 1 if not errorlevel 2 echo No differences found!!
RO> if errorlevel 0 if not errorlevel 1 beep
RO> echo.
RO> When FC finds differences these are output with ***** lines
RO> alternating between defining the start (with filename) and the end
RO> of a difference section.
RO> When no differences are found the ***** lines will not be written.
RO> FIND will throw up when differences are found between executable
RO> files because of the lo-ASCII characters. But you only need to find
RO> the first ***** line, isn't it?!
Here's another approach that doesn't depend on errorlevels at all:
@echo off
:COMPARE.BAT - Compare two specified files
if (%2)==() goto Syntax
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
if not exist %1 goto File1err
if not exist %2 goto File2err
:Begin
fc %1 %2|find "FC: no differences encountered">~.tmp
copy ~.tmp+,,>nul
if exist ~.tmp goto NoDifferences
echo Files "%1" and "%2" are different
goto End
:NoDifferences
echo Files "%1" and "%2" are the same
goto End
:File1err
echo Couldn't locate file %1
goto End
:File2err
echo Couldn't locate file %2
goto End
:Syntax
echo COMPARE [d:][\path]filename.[ext] [d:][\path]filename.[ext]
:End
RO> I don't know COMP but probably one could do something similar.
Yep. Here's a variation on the above that uses COMP instead of FC:
@echo off
:COMPARE.BAT - Compare two specified files
if (%2)==() goto Syntax
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
if not exist %1 goto File1err
if not exist %2 goto File2err
:Begin
ctty nul
echo n|comp %1 %2|find "Files compare OK">~.tmp
ctty con
copy ~.tmp+,,>nul
if exist ~.tmp goto NoDifferences
echo Files "%1" and "%2" are different
echo.
goto End
:NoDifferences
echo Files "%1" and "%2" are the same
echo.
goto End
:File1err
echo Couldn't locate file %1
goto End
:File2err
echo Couldn't locate file %2
goto End
:Syntax
echo COMPARE [d:][\path]filename.[ext] [d:][\path]filename.[ext]
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 444 Date: 12 Aug 96 17:57:00
From: Rob Oosten Read: Yes Replied: No
To: Richard Moore Mark:
Subj: Choice
──────────────────────────────────────────────────────────────────────────────
Richard,
on: 03 August 1996 at 19:57
you wrote
to: All
RM> Hi,
RM> I was wondering how I could make a simple batch
RM> file(s) like a menu kind of thing useing dos's
RM> choice.com??
Like this:
==================================================
== ========== Begin quote menu.bat ==========
@echo off
:START
cls
echo.
echo.
echo What is it you want to do?
echo.
echo A Nothing
echo B Something
echo C WordPerfect 5.1 DOS
echo D WfW 3.11
echo E Aldus PageMaker
echo F Corel Draw
echo G Word for Windows 6.0
echo H FD/GoldED
echo I Cookery Book
echo J Count my batches
echo K . . .
echo L . . .
echo M . . .
echo N . . .
echo.
echo Q Quit to DOS
echo.
say Hit the key of your choice . . . .
choice /c:ABCDEFGHIJKLMNQ /n
echo.
if errorlevel 15 if not errorlevel 16 goto END
if errorlevel 14 if not errorlevel 15 echo . . .
if errorlevel 13 if not errorlevel 14 echo . . .
if errorlevel 12 if not errorlevel 13 echo . . .
if errorlevel 11 if not errorlevel 12 echo . . .
if errorlevel 10 if not errorlevel 11 call countum
if errorlevel 9 if not errorlevel 10 call cookum
if errorlevel 8 if not errorlevel 9 call fd
if errorlevel 7 if not errorlevel 8 call winword
if errorlevel 6 if not errorlevel 7 call wincorel
if errorlevel 5 if not errorlevel 6 call winaldus
if errorlevel 4 if not errorlevel 5 call win
if errorlevel 3 if not errorlevel 4 call wp
if errorlevel 2 if not errorlevel 3 echo My choice? . . .
if errorlevel 1 if not errorlevel 2 echo It's your choice . . .
goto START
:END
== ========== End quote menu.bat ==========
==================================================
Just make sure this file is in your path. Also the other batches to start the
applications have to be in your path.
Make sure these applications/batches all end with errorlevel 0 and you'll
always return to the menu screen.
Cheerio,
Rob
-!- GED 2.50+/GEcho 1.11+/FD
! Origin: Point Suameer via ProgTel Drachten / Netherlands (2:500/100.6047)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 13 Aug 96 14:46:06
From: Vernon Frazee Read: Yes Replied: No
To: Mike Hill Mark:
Subj: CHANGE Program
──────────────────────────────────────────────────────────────────────────────
13-Aug-1996 14:46
Hello Mike,
On 10-Aug-96 at 14:54:00, "Roy Reed" and "Mike Hill" were discussing
"CHANGE Program":
MH> I now need to find a way to add a <012> character to the end of each
MH> file (page feed character). Can you suggest something which will do
MH> this?
Here's one way to do it. First you need a one-byte file containing
nothing but the FormFeed character (ASCII 12 / [Ctrl-L]). (I say
"nothing but" here because you probably do NOT want the addiional
carriage-return line-feed characters that would be right after the
FormFeed character if you used an editor or the DOS echo command).
Change to the directory containing your files and type: COPY CON FF
The cursor will drop down a line and be waiting for you to type in
something. Press [Ctrl-L], [Ctrl-Z], then [Enter] and DOS will
respond with "1 file(s) copied". Here, it'll look like this:
G:\>copy con ff
^L^Z
1 file(s) copied
Now you can use the COPY command to append the contents of your new
FF file to the end of each of your files with a for-in-do command:
for %x in (AEW01*.ASC) do copy %x+ff
MH> Once this is done, then I need to copy all files (395 of them total)
MH> and add them into one big file. The following command will do that,
MH> but I am open to suggestions on better ways:
MH>
MH> FOR %a in (AEW01*.ASC) do TYPE %a >>BOOK
That'll do it, assuming all of the files are in the correct order
of course. If they're not, you'd either have to get them sorted
correctly first or use something like:
copy book+awew0101.asc+awew0102.asc+awew0103.asc+awew0104.asc
copy book+awew0105.asc+awew0106.asc+awew0107.asc+awew0108.asc
...
copy book+awew0392.asc+awew0393.asc+awew0394.asc+awew0395.asc
(a major pain!) or maybe something like:
@echo off
:MAKEBOOK.BAT ------------------------------------------
:Open a 0-byte file named BOOK
rem>book
:Initialize COUNT variable
set COUNT=0
:Initialize temporary count file
rem>temptemp.dat
:OnesLoop ----------------------------------------------
:Increment the count by 1
echo !>>temptemp.dat
find "!" /c temptemp.dat>temptemp.bat
echo set COUNT=%%2>--------.bat
call temptemp.bat
:Does the require file exist?
if not exist awew000%COUNT%.asc goto Err
:Display what's happening
echo COPYing BOOK+AWEW000%COUNT%.ASC ...
:Append file BOOK
copy book+awew000%count%.asc>nul
if not (%COUNT%)==(10) goto OnesLoop
:TensLoop ----------------------------------------------
:Increment the count by 1
echo !>>temptemp.dat
find "!" /c temptemp.dat>temptemp.bat
echo set COUNT=%%2>--------.bat
call temptemp.bat
:Does the require file exist?
if not exist awew000%COUNT%.asc goto Err
:Display what's happening
echo COPYing BOOK+AWEW00%COUNT%.ASC ...
:Append file BOOK
copy book+awew00%count%.asc>nul
if not (%COUNT%)==(100) goto TensLoop
:HundredsLoop ------------------------------------------
:Increment the count by 1
echo !>>temptemp.dat
find "!" /c temptemp.dat>temptemp.bat
echo set COUNT=%%2>--------.bat
call temptemp.bat
:Does the require file exist?
if not exist awew000%COUNT%.asc goto Err
:Display what's happening
echo COPYing BOOK+AWEW0%COUNT%.ASC ...
:Append file BOOK
copy book+awew0%count%.asc>nul
if not (%COUNT%)==(396) goto HundredsLoop
goto Cleanup
:Err ---------------------------------------------------
echo The next required AWEW file (#%COUNT%) is missing!
:Cleanup -----------------------------------------------
set COUNT=
for %%x in (bat dat) do del temptemp.%%x
del --------.bat
:End ---------------------------------------------------
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 13 Aug 96 15:47:03
From: Vernon Frazee Read: Yes Replied: No
To: Steve Rischke Mark:
Subj: Ver command
──────────────────────────────────────────────────────────────────────────────
13-Aug-1996 15:47
Hello Steve,
On 11-Aug-96 at 00:53:00, "All" and "Steve Rischke" were discussing
"Ver command":
SR> I am looking for a command thet will check the version of the
SR> opperating system & then process a command based upon what it finds.
SR> I am running dos & OS/2. I want something to check when in a dos
SR> window from OS/2 to see if it's the cerrent system run this command
SR> as well as the ability to check if it's the dos system. This being
SR> accomplished in seperate lines is great.
SR>
SR> eg. if ver = msdos 6.20 then lh cdrom.com
SR> if ver = OS/2 3.0 then lh cdrom2.com
You might try something like this:
@echo off
:Are we running MS-DOS?
ver|find "MS-DOS Version 6.22"
if errorlevel 0 if not errorlevel 1 goto MSDOS
:Must be running OS/2
lh cdrom2.com
goto End
:MSDOS
lh cdrom.com
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 441 Date: 21 Aug 96 20:00:23
From: Gerry Ellison Read: Yes Replied: No
To: Wayne Allen Mark:
Subj: Date files
──────────────────────────────────────────────────────────────────────────────
WA> does anyone know how I insert a date into a filename in a
WA> batch file. the idea is to save a log file each night automatically
WA> so at the end of say a week I have 7 seperate files... do'nt have to
WA> be dated although it would be nice numbers would also do i.e Jan 1st
WA> is LG001.txt and Christmas day is LG365.txt......
------------------- <TMT> --------------------
Hello Wayne!
Try this with ARJ. run as often as you want.
save.bat
ARJ m BB -h# Max01.log Bink_01.log -jm
ARJ m -v1440r50K #96logs BB??????.ARJ
Makes #96LOGS .ARJ
that contains
BB960630 ARJ
which contains
MAX01.LOG
BINK_01.LOG
Regards, Gerry
-!- timEd 1.10+
! Origin: The Mountain Top Genealogy BBS *OH* 513-921-5568 V34+ (1:108/107)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 434 Date: 21 Aug 96 22:52:20
From: Larry Nelson Read: Yes Replied: No
To: All Mark:
Subj: Comx.bat
──────────────────────────────────────────────────────────────────────────────
ALL:
Use #1 for the script produced by Vernons COM2BAT.BAT
:: COMX.BAT/DOS 6.20
:: Repository and database for .com utilities.
@echo off
cls
if not %1! == ! goto %1
echo.
echo Welcome to COMX, the Store House for all those little
echo Batch utilities that are cluttering your \utl directory
echo and taking up disk space with less that cluster size
echo files.
echo.
echo Input a utility name from the list below and COMX
echo will crank out a .com program for you, of the same name.
echo If you already know which utility you need COMX.BAT
echo may be called from the command line with a parameter
echo equal to the name of your choice. Name only, no .ext.
echo.
echo Please make sure that Debug, Qbasic, Find and Mode are
echo in path, and you have at least 50 bytes of DOS
echo Environment space. Ctrl/c now or....
echo When prompted for input. Input x to exit COMX.BAT
echo .....If you need to check on these requirements.
echo.
echo Calling Comx with a parameter of "utls", less quots,
echo will bring to the screen a bare list of names. Bypassing
echo this screen and the more discriptive list of utilities.
echo.
pause
:: Discriptive list of .coms starts here.
echo.
echo BORDER:
echo Border.com sets border color from the command line
echo or can be called from a Batch file.
echo.
echo SYNTAX = border n
echo Where n = 0 = Black
echo 1 = Blue
echo 2 = Green
echo 3 = Cyan
echo 4 = Red
echo 5 = Magenta
echo 6 = Brown
echo 7 = White
echo 8 = Grey
echo 9 = Bright blue
echo a = Bright green
echo b = Bright cyan
echo c = Bright red
echo d = Bright magenta
echo e = Yellow
echo f = Bright white
echo.
echo.
:: This demo holds only one stored utility. In theroy it could
:: hold as many as you might care to install.
echo Please input your choice by name only, no .ext.....
fc con nul/lb1/n|date|find " 1: ">ente2.bat
echo set npt=%%5>enter.bat
call ente2
for %%q in (!x !) do if %npt%! == %%q goto cleanup
%0 %npt%
:border
if not %1! == ! set npt=%1
echo Creating %npt%.COM ...
echo n%npt%.com>%npt%.scr
echo e0100 BE 80 00 8B 0C 32 ED E3 31 FE C9 46 46 8A 1C 80>>%npt%.scr
echo e0110 FB 30 72 1B 80 FB 39 76 10 80 E3 DF 80 FB 41 72>>%npt%.scr
echo e0120 0E 80 FB 46 77 09 80 EB 07 80 EB 30 EB 06 90 E2>>%npt%.scr
echo e0130 DB EB 07 90 B4 0B 32 FF CD 10 CD 20 28 63 29 20>>%npt%.scr
echo e0140 31 39 38 38 20 5A 69 66 66 20 43 6F 6D 6D 75 6E>>%npt%.scr
echo e0150 69 63 61 74 69 6F 6E 73 20 43 6F 2E>>%npt%.scr
echo rcx>>%npt%.scr
echo 5C>>%npt%.scr
echo w>>%npt%.scr
echo q>>%npt%.scr
debug<%npt%.scr>nul
del %npt%.scr
dir %npt%.COM
goto cleanup
:utls
echo Border
:cleanup
if exist ente?.bat del ente?.bat
set npt=
:L8r
I keep Comx.bat in \utl (in path) and when I run it the
resulting utility shows up in the current directory.
:L8r
Larry
..... In a pinch a stone ax still works.....
-!- Maximus 2.02
! Origin: MSDOS MAXIMUS BBS (1:343/101)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 441 Date: 24 Aug 96 01:35:00
From: Irv Luckom Read: Yes Replied: No
To: Jon Jaeschke Mark:
Subj: In Need Of Assistance...
──────────────────────────────────────────────────────────────────────────────
JJ> FF> Just so I understand you, you want to copy everthing in the
JJ> FF> \AMIPRO\DATA directory onto floppies, and there is more than 1.4mb of
JJ> FF> files in the DATA directory, so you need to change floppies during the
JJ> FF> copy, and you want a batch file to automate the process?
If you have a copy of PKZIP what you want to do can be done in one
simple step. (If you don't have a copy virtually every BBS I have been
on has it in its files section.)
The command is:
pkzip -ex -rp -&f [[d:]zipfile name you select] [directory name]
If you want to use this with different zipfile and directory names you
could create the following 2 line batch file and name it back.bat:
@echo off
pkzip -ex -rp -&f %1 %2
You would call this batch file with the command:
back [[d:]zipfile name you select] [directory name]
For example: back a:prozip \amipro\data
The pkzip command will format your backup disks, preserve your
directory structure, ask you for another disk when it fills the first
one, and put a directory of all the files backed up on the last disk
used.
To reverse this and reload the backed up files to their original
directories if the backup files are later dates than the files now in
those directories, the command is:
pkunzip -d -n a:prozip
If you want everything you have backed up, delete the -n in the previous
line.
___
X SLMR 2.1a X
-!- Maximus 3.01
! Origin: Eye Of The Storm * West Palm Beach, FL (1:3609/67)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 443 Date: 02 Sep 96 08:38:37
From: Vernon Frazee Read: Yes Replied: No
To: Bill Casey Mark:
Subj: Removing ">" sign from text files
──────────────────────────────────────────────────────────────────────────────
BC> Greetings from Birmingham England.
Kewl! Aren't ya'll the ones that frequently use the word "bloody"
as an adverb? 8-)
BC> ... is it possible to write a batch file that would remove the ">"
BC> sign from the beginning of each line in a text file? ...
Here's an example of one way to do it:
@echo off
:STRIP62.BAT - Strip greater-than symbol (ASCII 62) from the
: beginning of each line in the specified file.
if (%1)==() goto Syntax
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
if not exist %1 goto FileErr
goto Initialize
:Syntax -------------------------------------------------------
echo Name: STRIP62.BAT
echo Purpose: Strip greater-than symbol (ASCII 62) from the
echo beginning of each line in the specified file.
echo Syntax: %0 [d:][\path\]filename.ext
echo Note: Requires QBASIC and FIND (somewhere in PATH) and
echo enough free space in the environment to hold the
echo length of your filename + 16 characters.
goto End
:Initialize variables -----------------------------------------
cls
for %%x in (DIR FN FE) do set ~%%x=
:Parse specified filename -------------------------------------
echo Parsing filename "%1" ...
:Put Directory name in evar ~DIR
dir %1.|find "Directory">~.bat
echo set ~DIR=%%2>director.bat
for %%x in (call del) do %%x ~.bat
del director.bat
:Append "\" to ~DIR?
if exist %~DIR%\nul set ~DIR=%~DIR%\
:Put filename in evar ~FN and file extension in evar ~FE
dir %1.|find /v "e"|find ":">~.bat
echo.>>~.bat
date<~.bat |find "Enter">~.bat
rem ------^------ This space must be here
echo set ~FN=%%4>enter.bat
echo if exist %%~DIR%%%%4.%%5 set ~FE=%%5>>enter.bat
for %%x in (call del) do %%x ~.bat
del enter.bat
:Create backup copy of original -------------------------------
echo Creating backup of "%1" named "%~DIR%%~FN%.BAK" ...
copy %1 %~DIR%%~FN%.BAK>nul
:Build QBASIC program using specified filename ----------------
echo Creating QBASIC program ...
echo open "%~DIR%%~FN%.BAK" for input as #1>~.bas
echo open "%~DIR%%~FN%.%~FE%" for output as #2>>~.bas
echo Count=0>>~.bas
echo do until eof(1)>>~.bas
echo line input #1,rec$>>~.bas
echo Count=Count+1:locate ,1:print "Line#:"; Count;>>~.bas
echo if not left$(rec$,1)=chr$(62) then>>~.bas
echo print #2,rec$>>~.bas
echo else>>~.bas
echo print #2,mid$(rec$,2,len(rec$))>>~.bas
echo end if>>~.bas
echo loop:print:close:system>>~.bas
:DoIt ---------------------------------------------------------
echo Stripping leading greater-than symbols
echo from each line in file "%~DIR%%~FN%.%~FE%" ...
qbasic /run ~.bas
del ~.bas
:Done ---------------------------------------------------------
echo.
echo Original file:
echo.
dir %~DIR%%~FN%.BAK|find ":"
echo.
echo Stripped file:
echo.
dir %~DIR%%~FN%.%~FE%|find ":"
echo.
for %%x in (DIR FN FE) do set ~%%x=
echo Processing complete.
echo.
goto End
:FileErr ------------------------------------------------------
echo Error: Could not locate file "%1"
goto Syntax
:End ----------------------------------------------------------
BC> PS: I hope your back is getting better.
Thanks; getting a little better every day.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 435 Date: 03 Sep 96 20:17:06
From: Andy Guess Read: Yes Replied: No
To: Simon Stone Mark:
Subj: Thanx
──────────────────────────────────────────────────────────────────────────────
SS> Thanks to all of you that helped with my problem with the TYPE
SS> command, there's just one thing left, |MORE dosn't work on the end
SS> of the command..
SS> === Cut ===[ t.bat ]===
SS> FOR %%A IN (*.MSG) DO TYPE %%A |MORE
SS> === Cut ===
SS> Why ??
You can't reliably use redirection symbols with FOR. I would try this
instead, which uses two batch files.
+=+=+=+=+ T.BAT +=+=+=+=+
@for %%a in (*.msg) do call aux.bat %%a
+=+=+=+=+ T.BAT +=+=+=+=+
+=+=+=+=+ AUX.BAT +=+=+=+=+
@more<%1
+=+=+=+=+ AUX.BAT +=+=+=+=+
Just type "T" to start it. Hope this helps!
{Write Back!} [/^\ndy Guess]
.!. We've secretly replaced the dilithium with new Folgers crystals
-!- Terminate 4.00
! Origin: -AG {andy.guess@myplace.blkcat.com} (1:109/570.15)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 05 Sep 96 08:17:57
From: Vernon Frazee Read: Yes Replied: No
To: Stefan Mensink Mark:
Subj: Nul
──────────────────────────────────────────────────────────────────────────────
5-Sep-1996 08:17
Hello Stefan,
On 29-Aug-96 at 17:24:14, "Russell Albee" and "Stefan Mensink" were
discussing "Nul":
RA> Is there anyway to use the nul to put a file to so that it cannot be
RA> recovered?
SM> ah.. you mean that you want to erase a file from your harddisk and
SM> it should not be recovered again? maybe you should try this
SM> del myfile.ext
SM> echo ehe can't get it back huh? >myfile.ext
SM> this means that part of the file should be directly overwritten so
SM> that undelete cannot restore it.. though more active protections
SM> might be able to restore it anyway or at least parts of it..
With a sector editor, more than likely every bit of it.
SM> what could also do is just delete the file and then start defrag or
SM> whatever defragmentation program and erase all free space ..
That'd probably do it. What I usually recommend is simply copying a
larger file over the one to be obliterated and then delete it. Since
the copy overwrote whatever was in the file you now have don't have
to worry about anyone retrieving it.
For example, here's a DIR listing of the original file to be erased:
Directory of G:\IRS\VJF\95
TAXCHEAT.95 91,022 04-15-96 11:55p
And a DIR listing of the file to copy over it:
Directory of C:\WINDOWS
SETUP EXE 422,080 03-10-92 3:10a
The commands that could be used to to obliterate it then are:
G:\IRS\VJF\95>copy c:\windows\setup.exe taxcheat.95
G:\IRS\VJF\95>echo Up Yours!>taxcheat.95
G:\IRS\VJF\95>del taxcheat.95
;-)
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 11 Sep 96 15:57:23
From: Vernon Frazee Read: Yes Replied: No
To: Allen Fraley Mark:
Subj: call command
──────────────────────────────────────────────────────────────────────────────
11-Sep-1996 15:57
Hello Allen,
On 08-Sep-96 at 20:44:00, "Richard Epling" and "Allen Fraley" were
discussing "call command":
AF> I want to run these bat file commands from my nightly maintenance
AF> imrun.bat file.
AF> call c:\allfix\saveit.bat
AF> call c:\gecho\saveit.bat
AF> call c:\amu\saveit.bat
AF> call c:\pb\saveit.bat
AF> call c:\im\saveit.bat
AF> Below is an example of saveit.bat in c:\allfix directory. All
AF> saveit.bat files are the same in each directory with the exception
AF> of the file name being zipped up.
AF> savit.bat
AF> pkzip allfix *.* -ex -rp -whs -Jhrs
AF> copy allfix.zip d:\allfix
AF> del allfix.zip
AF> If I run saveit.bat from there home directories, they work just
AF> fine, zipping up all files and directories. Then the zip files are
AF> copied to there respective directories on my d: drive for storage.
AF> But I want to call each one of them from imrun.bat which runs my
AF> nightly maintenance routine.
AF> The above call commands do not work from my imrun.bat file. By the
AF> way, each one of the above directories are in my autoexec path
AF> statement. Could this be causing me some problems being that the
AF> bats have the same name? Is there maybe a simpler way to do this?
Here's an IMRUN.BAT for you that will do everything you are trying
to do in a single command:
@for %%x in (allfix gecho amu pb im) do pkzip -ex -rp -whs ...
... -Jhrs d:\%%x\%%x.zip c:\%%x\*.*
Note: Remove the 3 trailing dots "..." from the end of the 1st
line and from the beginning of the 2nd line and join the
2 lines together with a space between "-whs" and "-Jhrs".
Here are the 5 commands, in order, that will actually be processed
as DOS expands the above FOR-IN-DO command:
pkzip -ex -rp -whs -Jhrs d:\allfix\allfix.zip c:\allfix\*.*
pkzip -ex -rp -whs -Jhrs d:\gecho\gecho.zip c:\gecho\*.*
pkzip -ex -rp -whs -Jhrs d:\amu\amu.zip c:\amu\*.*
pkzip -ex -rp -whs -Jhrs d:\pb\pb.zip c:\pb\*.*
pkzip -ex -rp -whs -Jhrs d:\im\im.zip c:\im\*.*
IOW, by using the power of PKZIP and the FOR-IN-DO command, you not
only save yourself a lot of grief in trying to keep up with those 6
separate BATch file, you also free up 5 clusters worth of valuable
hard drive space.
Speaking of which, since you are creating 5 separate uniquely named
ZIPs anyway you could save even a little more room by deleting the 5
separate directories on drive D: and then create all of your backup
ZIPs in a single directory, say "D:\BACKUPS":
@for %%x in (allfix gecho amu pb im) do pkzip -ex -rp -whs ...
... -Jhrs d:\backups\%%x.zip c:\%%x\*.*
After you get through running this one you would have something like
Volume in drive D is DRIVE0_VOL2
Directory of D:\BACKUPS
ALLFIX ZIP 51,645 09-11-96 3:57p
GECHO ZIP 42,754 09-11-96 3:57p
AMU ZIP 154,391 09-11-96 3:57p
PB ZIP 14,433 09-11-96 3:57p
IM ZIP 1,759,992 09-11-96 3:57p
5 file(s) 2,023,215 bytes
209,699,328 bytes free
(instead of each file in a separate directory).
Just a thought; either way will work.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 446 Date: 11 Sep 96 18:26:56
From: Vernon Frazee Read: Yes Replied: No
To: Richard Morrell Mark:
Subj: change a line
──────────────────────────────────────────────────────────────────────────────
11-Sep-1996 18:26
Hello Richard,
RM> Can anyone tell me if theres a way to change ...
If deleting ALL of the > (greater-than) characters in a file isn't
a problem, here's an example of "how to" using EDLIN:
@echo off
:EXAMPLE of how to strip ">"'s using EDLIN
if (%1)==() goto Syntax
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
if not exist %1 goto FileErr
:Create temporary EDLIN script file
echo"1,#r>" >~.scr
rem -------^------- ASCII 8 (backspace)
echo e>>~.scr
:Strip ">"'s from the specified file
edlin %1<~.scr>nul
del ~.scr
:Done
echo A backup copy of your original file
echo was saved with the extension .BAK
goto End
:FileErr
echo Error: "%1" could not be located
:Syntax
echo Syntax: EXAMPLE filename[.ext]
:End
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 447 Date: 11 Sep 96 16:57:44
From: Vernon Frazee Read: Yes Replied: No
To: Stefan Mensink Mark:
Subj: Nul
──────────────────────────────────────────────────────────────────────────────
11-Sep-1996 16:57
Hello Stefan,
On 06-Sep-96 at 19:08:09, "Martin Whittaker" and "Stefan Mensink"
were discussing "Nul":
MW> Vernon Frazee posted a little gem here awhile back (now _that's_ an
MW> understatement :)) - which included a basic routine to do just what
MW> the originator of this thread was after (I think)....clearing a
MW> file's contents to "nul" (or all 0's or whatever i.e. meaningless
MW> data).
SM> you mean like a program that was written in the lang. basic, to be
SM> used in batchfiles? in that case .. pity.. otherwise.. i'd be really
SM> interested how he'd implement that in batch.. you see.. basic
SM> executables are so awfully big.. ;[
It's self-contained. Here, try it:
@echo off
:WIPE_IT.BAT v1.10 ------------------------------------
:Wipes, renames, and then deletes the specified file.
:Begin ------------------------------------------------
if not (%1)==() goto CheckParms
:Syntax -----------------------------------------------
echo Name: WIPE_IT.BAT v1.10
echo Purpose: Wipes, renames, and then deletes the
echo specified file.
echo Syntax: WIPE_IT [d:][\path\]filename[.ext]
echo Example: WIPE_IT TAXCHEAT.95
echo Needed: QBASIC and CHOICE (anywhere in PATH)
goto End
:CheckParms -------------------------------------------
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
if not exist %1 goto InputErr
:Are you sure? ----------------------------------------
echo Are you sure you want to wipe file "%1"?
choice /c:yn /n "[Y]es or [N]o (Y/N): "
if errorlevel 2 goto Abort
:Create/Run QBASIC program to wipe file ---------------
echo open "%1" for binary as #1>>~.bas
echo length=lof(1): close #1>>~.bas
echo lines=int(length/512)>>~.bas
echo if not length mod 512=0 then>>~.bas
echo lines=lines+1>>~.bas
echo end if>>~.bas
echo open "%1" for output as #1>>~.bas
echo for x=1 to lines>>~.bas
echo locate,1:print "Goal:";lines;" Line:";x;>>~.bas
echo print #1, string$(512,chr$(246));>>~.bas
echo next x:close:print:randomize timer>>~.bas
echo x$="~"+right$(str$(cdbl(rnd)),7)+".tmp">>~.bas
echo name "%1" as x$: kill x$: system>>~.bas
qbasic /run ~.bas
del ~.bas
echo "%1" was wiped, renamed, then deleted.
goto End
:InputErr ---------------------------------------------
echo Error: "%1" does not exist
goto Syntax
:Abort ------------------------------------------------
echo All processing aborted.
:End -------------------------------------------- -vjf-
Example: WIPE_IT TAXCHEAT.95
<g>
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 449 Date: 17 Sep 96 10:11:04
From: Larry Nelson Read: Yes Replied: No
To: Jim Danvers Mark:
Subj: Need to parse a file
──────────────────────────────────────────────────────────────────────────────
JIM:
Subject: Need to parse text file....
JD> We have determined that by simply removing a line from the system.ini
JD> file in thier win 3.x systems - the can switch from the local
JD> network/Wan to thier ISP. Easy - but right at the moment the line
JD> removal has/is being done manually. I'd like to come up with a batch
JD> solution......
What a great use for Batch in the daily hassel of life at
the keyboard. You didn't mention just which line needed
cutting from System.ini so I chose the one that required the
least typing ("type=4") See what you think of this....
::WanWacker.BAT/DOS 6.22
@echo off
cls
find/v "type=4"<C:\windows\system.ini>C:\windows\system.ini
:L8r
I tied it to an icon in Windows and it seemed to run nicely.
:L8r
Larry
.....In a pinch a stone ax still works.....
-!- Maximus 2.02
! Origin: MSDOS MAXIMUS BBS (1:343/101)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 437 Date: 23 Sep 96 07:15:18
From: Vernon Frazee Read: Yes Replied: No
To: WAYNE ALLEN Mark:
Subj: Date driven BAT's
──────────────────────────────────────────────────────────────────────────────
23-Sep-1996 07:15
Hello WAYNE,
On 17-Sep-96 at 21:31:04, "All" and "WAYNE ALLEN" were discussing
"Date driven BAT's":
WA> How do I get a .BAT to activate automatically on a specific date?,
WA> preferably once only (I could use sepaphores to do that bit).
If you boot your system every day A-N-D your birthday is September
23rd, here's an example that can be appended to your AUTOEXEC.BAT:
::------------------------------------------------------------------
::Birthday? - If the current system date is 09-23-(any year), AND we
::have not done so yet this day, display "Happy Birthday!" and pause
::------------------------------------------------------------------
ver|date|find " 09-23-"
if errorlevel 0 if not errorlevel 1 goto DisplayBirthday?
if exist birthday.$$$ del birthday.$$$
goto EndBirthDayRoutine
:DisplayBirthday? - (Only if "birthday.$$$ does NOT exist) ---------
if exist birthday.$$$ goto EndBirthdayRoutine
rem>birthday.$$$
echo.
echo Happy Birthday!
echo.
pause
:EndBirthdayRoutine ------------------------------------------------
Of course this can be easily altered to work with any:
Day of the week - have FIND look for "Mon" or "Tue" or "Wed", etc.
~~~~~~~~~~~~~~~
Day - have FIND look for "-01-" or "-02-" or "-03-", etc.
~~~ (note the dashes ---^--^ on either side of the numbers)
Month - have FIND look for " 01" (Jan) or " 02" (Feb), etc.
~~~~~ (leading spaces ----^--------------^)
Friday the 13th - ver|date|find "Fri"|find "-13-"
~~~~~~~~~~~~~~~
Anniversary - Some important anniversary/date is September the 5th
~~~~~~~~~~~ and you want a few days advance/repetitive notice so
you hopefully won't forget to purchase something:
ver|date|find " 09-0"
etc., etc., etc.
And/or then of course to do whatever you need it to do when such
proves true (errorlevel 0) and/or false (errorlevel 1).
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 441 Date: 23 Sep 96 16:45:53
From: Vernon Frazee Read: Yes Replied: No
To: Simon Stone Mark:
Subj: Search
──────────────────────────────────────────────────────────────────────────────
23-Sep-1996 16:45
Hello Simon,
On 21-Sep-96 at 00:31:47, "All" and "Simon Stone" were discussing
"Search":
SS> Is there a way of making a BAT file to search and delete files on my
SS> machine ??
1) Stick the following SWEEP.BAT in a directory in your PATH
@echo off
:SWEEP.BAT - Original from PC Computing
if not (%1)==() goto Begin
:Syntax -----------------------------------------------------
echo Name: SWEEP.BAT
echo Purpose: Execute specified command in every directory
echo Syntax: SWEEP command [parameters]
goto End
:Begin ------------------------------------------------------
if (%1)==(?) goto Syntax
if (%1)==(/?) goto Syntax
set SWEEP=%1 %2 %3 %4 %5 %6 %7 %8 %9
cls
echo Creating a list of all directories on current drive ...
echo @prompt set CurrentDIR=$p>tmptmp.bat
command /e:2048 /c tmptmp.bat>director.bat
del tmptmp.bat | call director.bat
echo @echo off>director.bat
echo prompt $g$h>>director.bat
echo cd %%1>>director.bat
echo %%SWEEP%%>>director.bat
echo cd %%CurrentDIR%%>>director.bat
chkdsk/v|find "Directory"|find "%CurrentDIR%">tmptmp.lst
echo exit>>tmptmp.lst
command<tmptmp.lst
echo Processing complete.
:Cleanup ----------------------------------------------------
for %%x in (tmptmp.lst director.bat) do if exist %%x del %%x
for %%x in (CurrentDIR SWEEP) do set %%x=
:End --------------------------------------------------------
2) Type something similar to the following:
SWEEP DEL the_name_of_the_file_you_want_to_delete_goes_here
Note: Since this command would delete ALL files matching the
filename you specified in your current directory and each
and every subdirectory below it, be careful -- especially
with wildcards. IOW, the command "SWEEP DEL *.*" from the
root directory of drive C: could be disastrous.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 448 Date: 27 Sep 96 00:21:22
From: Larry Nelson Read: Yes Replied: No
To: All Mark:
Subj: LazyDayz.bat
──────────────────────────────────────────────────────────────────────────────
ALL:
What day does the Fourth of July fall on next year?
Don't know huh. Well now you don't have to go asking
dumb questions of people that prolly don't know either.
Just run LazyDayz.bat and be no longer damned to the
ranks of the ignorant.
:: LAZYDAYZ.BAT/DOS 6.22, 7.0
:: Determines the day of the week for any date
:: from (on my sysem) 01-01-80 to 12-31-2099.
@echo off
cls
if %1! == ! goto hlp
ver|date|find "Current">curren1.bat
echo set cur=%%4>current.bat
call curren1
echo %1|date>nul
ver|date|find "Current">curren1.bat
echo set dow=%%3>current.bat
call curren1
echo %1 Falls on a %dow%
echo %cur%|date>nul
del curren?.bat
set cur=
set dow=
goto L8r
:hlp
echo SYNTAX = dayz (target date)
echo.
echo Sample:
echo dayz 12-34-96
:L8r
BTW this runs faster in when I run it while shelled out
of win95 into DOS 7.0.
:L8r
Larry
.....Ina pinch a stone ax still works.....
-!- Maximus 2.02
! Origin: MSDOS MAXIMUS BBS (1:343/101)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 438 Date: 26 Sep 96 10:00:51
From: Vernon Frazee Read: Yes Replied: No
To: RICHARD BASH Mark:
Subj: Capturing date and time
──────────────────────────────────────────────────────────────────────────────
26-Sep-1996 10:00
Hello RICHARD,
On 23-Sep-96 at 19:01:25, "ALL" and "RICHARD BASH" were discussing
"Capturing date and time":
RB> I am using MS-DOS 6.22 along with DESWview. How can I creatively
RB> capture the current date and time in a constantly running batch
RB> file? Said batch file would check the date and time against a
RB> desired date (or day) and time and if there was a "hit," the batch
RB> file would call another batch file. If no "hit," the batch file
RB> would loop back to the start of the file. This batch file would run
RB> in a DV window in the background.
Here's one simple way to do it:
::------------------------------------------
::Stick the current date and time in evar DT
::------------------------------------------
echo prompt %prompt%>userpmpt.bat
prompt set dt=$d $t>temptemp.bat
command /c temptemp.bat>temptemp.bat
for %%x in (call del) do %%x userpmpt.bat
for %%x in (call del) do %%x temptemp.bat
::------------------------------------------
For example, the string this would leave in the environment right
now would be:
DT=Thu 09-26-1996 10:03:20.89
You could then use FIND (from MS-DOS version 6.nn+) to look for any
of the following strings:
"Thu" (Weekday)
" 09" (Month)
"-26-" (Day)
"96 " (Year)
"10:" (Hour)
":03:" (Minute)
and use its returned errorlevel to determine if you found a hit.
For example, is it Monday?
set|find "DT="|find "Mon">nul
if errorlevel 0 if not errorlevel 1 __________
(where "__________" is maybe a "GOTO whatever_label", or "CALL
whatever_BATch_file" or do "whatever command") when the current
system weekday is Monday.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)
─ Area: Batch Language Programming FI ────────────────────
Msg#: 445 Date: 01 Oct 96 19:40:12
From: Vernon Frazee Read: Yes Replied: No
To: Brian Fields Mark:
Subj: Batch by date
──────────────────────────────────────────────────────────────────────────────
1-Oct-1996 19:40
Hello Brian,
On 30-Sep-96 at 13:28:53, "Larry Nelson" and "Brian Fields" were
discussing "Re: Batch by date":
BF> Ok... Datecheck is designed to execute certain batch files by name,
BF> or create certain semaphores depending on the conditions defined by
BF> the user. You can execute a batch (or create a semaphore) Daily,
BF> Weekly, Monthly, User defined interval (x days), Yearly, on a
BF> specific Date, (MM-DD.BAT), on a specific day, (Monday.BAT, etc...)
BF> Can ya handle that? :)
Today, the first line from the output of the command "ver|date" is
"Current date is Tue 10-01-1996" which contains quite a bit of info
that can be used with FIND. For example,
:On every "Tue" do whatever
ver|date|find "Tue">nul
if errorlevel 0 if not errorlevel 1 whatever
:On every day BUT Sun
ver|date|find /v "Sun"
if errorlevel 1 whatever
:Only on the 1st of every month
ver|date|find "-01-">nul
if errorlevel 0 if not errorlevel 1 whatever
:Only if it's Friday the 13th
ver|date|find "Fri"|find "-13-"
if errorlevel 0 if not errorlevel 1 echo Horror!
:Only on Christmas Day
ver|date|find "12-25-">nul
if errorlevel 0 if not errorlevel 1 echo Merry Christmas!
:Only during October
ver|date|find " 10-">nul
if errorlevel 0 if not errorlevel 1 whatever
:From the 10th thru the 19th of October
ver|date|find " 10-1"
if errorlevel 0 if not errorlevel 1 Anniversary on the 20th!
:Only on Sadie Hawkins day (leap day)
ver|date|find "02-29-">nul
if errorlevel 0 if not errorlevel 1 whatever
etc., etc.
I've been using the idea for years and will admit that it does have
it's limitations but, it doesn't cost a cent extra and is almost
always readily available on millions of DOS machines.
-- NetMail: 1:135/71.17 E-Mail: vernon.frazee@sunshine.com -vjf-
-- Main BossNode: SOX! BBS * (305) 821-3317 * Hialeah FL USA * 1:135/71
-!- Terminate 4.00/Pro
! Origin: Vern's Point * Hollywood Lakes, Florida * USA * (1:135/71.17)